From 672dd50b7fa93846c204ee0c54e0ccd60556c410 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 29 Jun 2022 10:51:11 +0900 Subject: [PATCH 01/16] Remove files and codes related to DBus Change-Id: I48d11a36f6551c9169d576218b9b56660de85489 Signed-off-by: sooyeon --- CMakeLists.txt | 6 +- client/CMakeLists.txt | 3 - client/vc.c | 1 - client/vc_dbus.c | 1998 ----------------------------------- client/vc_dbus.h | 83 -- client/vc_mgr.c | 10 +- client/vc_mgr_dbus.c | 794 -------------- client/vc_mgr_dbus.h | 43 - client/vc_setting.c | 1 - client/vc_setting_dbus.c | 384 ------- client/vc_setting_dbus.h | 38 - common/vc_main.h | 1 - include/voice-control-engine.pc.in | 2 +- include/voice-control-manager.pc.in | 2 +- include/voice-control-widget.pc.in | 2 +- include/voice-control.pc.in | 2 +- org.tizen.voice.vcserver.service | 5 - org.tizen.voice.vcserver.tv.service | 4 - packaging/voice-control.spec | 3 - server/CMakeLists.txt | 2 - server/vcd_dbus.c | 546 ---------- server/vcd_dbus.h | 38 - server/vcd_dbus_server.c | 1469 ------------------------- server/vcd_dbus_server.h | 105 -- server/vcd_engine_agent.c | 1 - server/vcd_server.c | 1 - server/vce.c | 7 - vc-server.conf | 19 - 28 files changed, 6 insertions(+), 5564 deletions(-) delete mode 100644 client/vc_dbus.c delete mode 100644 client/vc_dbus.h delete mode 100644 client/vc_mgr_dbus.c delete mode 100644 client/vc_mgr_dbus.h delete mode 100644 client/vc_setting_dbus.c delete mode 100644 client/vc_setting_dbus.h delete mode 100644 org.tizen.voice.vcserver.service delete mode 100644 org.tizen.voice.vcserver.tv.service delete mode 100644 server/vcd_dbus.c delete mode 100644 server/vcd_dbus.h delete mode 100644 server/vcd_dbus_server.c delete mode 100644 server/vcd_dbus_server.h delete mode 100644 vc-server.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index aca3b41..daa639f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 - capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf gmock bundle rpc-port + capi-system-info cynara-client cynara-session db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf gmock bundle rpc-port ) @@ -71,10 +71,6 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/voice-control.info DESTINATION ${TZ_SYS_RO_SHA ## config ## INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION ${TZ_SYS_RO_SHARE}/voice/vc/1.0) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.vcserver.service DESTINATION ${TZ_SYS_RO_SHARE}/dbus-1/services) - -INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-server.conf DESTINATION /etc/dbus-1/session.d) - ## vc_getengine ## IF("${ARCH}" MATCHES "^arm.*") INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/armv7l/vc_getengine DESTINATION ${TZ_SYS_BIN}) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index b5ddb82..17a0edd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -2,7 +2,6 @@ SET(SRCS vc.c vc_data.cpp vc_client.c -# vc_dbus.c vc_tidl.c vc_proxy.c ../common/vc_cmd_db.c @@ -15,7 +14,6 @@ SET(SRCS ) SET(SETTING_SRCS -# vc_setting_dbus.c vc_setting_tidl.c vc_setting_proxy.c vc_setting.c @@ -46,7 +44,6 @@ SET(MANAGER_SRCS vc_mgr_tidl.c vc_mgr_proxy.c vc_mgr_stub.c - vc_mgr_dbus.c ../common/vc_cmd_db.c ../common/vc_command.c ../common/vc_command_util.c diff --git a/client/vc.c b/client/vc.c index 4dbb113..dd7be5a 100644 --- a/client/vc.c +++ b/client/vc.c @@ -30,7 +30,6 @@ #include "vc_command.h" #include "vc_config_mgr.h" #include "vc_data.h" -// #include "vc_dbus.h" #include "vc_tidl.h" #include "vc_info_parser.h" #include "vc_json_parser.h" diff --git a/client/vc_dbus.c b/client/vc_dbus.c deleted file mode 100644 index 05e5bed..0000000 --- a/client/vc_dbus.c +++ /dev/null @@ -1,1998 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "vc_command.h" -#include "vc_dbus.h" -#include "vc_main.h" - -static pthread_mutex_t g_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; - -static int g_waiting_time = 3000; -static int g_waiting_short_time = 200; -static bool g_is_connection_opened = false; - -static Ecore_Fd_Handler* g_fd_handler = NULL; - -static DBusConnection* g_conn_sender = NULL; -static DBusConnection* g_conn_listener = NULL; - -extern int __vc_cb_error(int reason, int daemon_pid, char* msg); - -extern int __vc_cb_error_to_app(int pid, int reason, char* msg); - -extern void __vc_cb_result(); - -extern int __vc_cb_service_state(int state); - -extern int __vc_cb_manager_pid(int manager_pid); - -extern int __vc_cb_tts_streaming(int utt_id, vc_feedback_event_e event, char* buffer, int len); - -extern int __vc_cb_utterance_status(int utt_id, int utt_status); - -//LCOV_EXCL_START -static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - break; - } - - DBusError err; - dbus_error_init(&err); - - char if_name[64] = {0, }; - snprintf(if_name, 64, "%s", VC_CLIENT_SERVICE_INTERFACE); - - if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_HELLO)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Hello"); - int pid = 0; - int response = -1; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (pid > 0) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get hello : pid(%d) ", pid); - response = 1; - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : invalid pid "); - } - - DBusMessage* reply = NULL; - 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_VCC, "@@ vc get hello : fail to send reply"); - else - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get hello : result(%d)", response); - - dbus_connection_flush(g_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* VCD_METHOD_HELLO */ - - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_SET_SERVICE_STATE)) { - int state = 0; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Get arguments error (%s)", err.message); - dbus_error_free(&err); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@ state changed : %d", state); - - __vc_cb_service_state(state); - - } /* VCD_METHOD_SET_SERVICE_STATE */ - - else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_RESULT)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result"); - - __vc_cb_result(); - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - } /* VCD_METHOD_RESULT */ - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_SEND_MANAGER_PID)) { - int manager_pid = 0; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &manager_pid, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Get arguments error (%s)", err.message); - dbus_error_free(&err); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@ manager pid is changed : %d", manager_pid); - - __vc_cb_manager_pid(manager_pid); - - } /* VCD_METHOD_SEND_MANAGER_PID */ - - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Error"); - int reason; - int daemon_pid; - char* err_msg; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &reason, - DBUS_TYPE_INT32, &daemon_pid, - DBUS_TYPE_STRING, &err_msg, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc Get Error message : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), daemon_pid(%d), msg(%s)", reason, daemon_pid, err_msg); - __vc_cb_error(reason, daemon_pid, err_msg); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* VCD_METHOD_ERROR */ - - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR_TO_APP)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Error and send to client app"); - int pid; - int reason; - char* err_msg; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &reason, - DBUS_TYPE_STRING, &err_msg, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc Get Error message : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", reason, pid, err_msg); - __vc_cb_error_to_app(pid, reason, err_msg); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* VCD_METHOD_ERROR_TO_APP */ - - else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_FEEDBACK_STREAMING)) { - SLOG(LOG_INFO, TAG_VCC, "@@@ Get TTS feedback streaming"); - int utt_id; - vc_feedback_event_e event; - char* buffer = NULL; - int len; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &event, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &buffer, &len, - DBUS_TYPE_INVALID); - - __vc_cb_tts_streaming(utt_id, event, buffer, len); - - SLOG(LOG_INFO, TAG_VCC, "@@@"); - } /* VCD_METHOD_FEEDBACK_STREAMING */ - - else if (dbus_message_is_method_call(msg, if_name, VC_MANAGER_METHOD_UTTERANCE_STATUS)) { - SLOG(LOG_INFO, TAG_VCC, "@@@ Get TTS utterance status streaming"); - int utt_id; - int utt_status; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &utt_status, - DBUS_TYPE_INVALID); - - __vc_cb_utterance_status(utt_id, utt_status); - - SLOG(LOG_INFO, TAG_VCC, "@@@"); - } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */ - - else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Owner Changed"); - DBusError err; - dbus_error_init(&err); - /* remove a rule for daemon error */ - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_conn_listener, rule_err, &err); - dbus_connection_flush(g_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); - dbus_error_free(&err); - } - - __vc_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* NameOwnerChanged */ - - else { - const char* sender = dbus_message_get_sender(msg); - const char* destination = dbus_message_get_destination(msg); - const char* path = dbus_message_get_path(msg); - const char* interf = dbus_message_get_interface(msg); - const char* member = dbus_message_get_member(msg); - int type = dbus_message_get_type(msg); - SLOG(LOG_ERROR, TAG_VCC, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } /* while(1) */ - - return ECORE_CALLBACK_PASS_ON; -} -//LCOV_EXCL_STOP - -static void __vc_dbus_connection_free() -{ - if (NULL != g_conn_listener) { - dbus_connection_close(g_conn_listener); - dbus_connection_unref(g_conn_listener); - g_conn_listener = NULL; - } - if (NULL != g_conn_sender) { - dbus_connection_close(g_conn_sender); - dbus_connection_unref(g_conn_sender); - g_conn_sender = NULL; - } -} - -int vc_dbus_open_connection() -{ - pthread_mutex_lock(&g_dbus_mutex); - - if (NULL != g_conn_sender && NULL != g_conn_listener) { - SLOG(LOG_WARN, TAG_VCC, "already existed connection "); //LCOV_EXCL_LINE - pthread_mutex_unlock(&g_dbus_mutex); - return 0; - } - - DBusError err; - int ret; - - /* initialize the error value */ - dbus_error_init(&err); - - /* connect to the DBUS system bus, and check for errors */ - g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection "); //LCOV_EXCL_LINE - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_sender, false); - - g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection "); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_listener, false); - - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - - SLOG(LOG_DEBUG, TAG_VCC, "service name is %s", service_name); - - /* register our name on the bus, and check for errors */ - ret = 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_VCC, "Name Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCC, "fail dbus_bus_request_name()"); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != g_fd_handler) { - SLOG(LOG_WARN, TAG_VCC, "The handler already exists."); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_NONE; - } - - char rule[256] = {0, }; - snprintf(rule, 256, "type='signal',interface='%s'", VC_CLIENT_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_conn_listener, rule, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCC, "fail to get fd from dbus "); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "Get fd from dbus : %d", fd); - } - - g_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL); - if (NULL == g_fd_handler) { - SLOG(LOG_ERROR, TAG_VCC, "fail to get fd handler from ecore "); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - g_is_connection_opened = true; - - pthread_mutex_unlock(&g_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCC, "[INFO] vc client dbus connection is opened"); - - return VC_ERROR_NONE; -} - -int vc_dbus_close_connection() -{ - pthread_mutex_lock(&g_dbus_mutex); - - DBusError err; - dbus_error_init(&err); - - if (NULL != g_fd_handler) { - ecore_main_fd_handler_del(g_fd_handler); - g_fd_handler = NULL; - } - - if (NULL != g_conn_listener) { - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - - dbus_bus_release_name(g_conn_listener, service_name, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - } - - __vc_dbus_connection_free(); - - g_is_connection_opened = false; - - pthread_mutex_unlock(&g_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCC, "[INFO] vc client dbus connection is closed"); - - return 0; -} - -int vc_dbus_reconnect() -{ - if (!g_conn_sender || !g_conn_listener) { - vc_dbus_close_connection(); - - if (0 != vc_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Reconnect"); //LCOV_EXCL_LINE - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); - SLOG(LOG_WARN, TAG_VCC, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); //LCOV_EXCL_LINE - - if (false == sender_connected || false == listener_connected) { - vc_dbus_close_connection(); - - if (0 != vc_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Reconnect"); //LCOV_EXCL_LINE - } - - return 0; -} - -static int __dbus_check() -{ - if (NULL == g_conn_sender || NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - return vc_dbus_reconnect(); - } - return 0; -} - -int vc_dbus_request_hello() -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Request vc hello"); //LCOV_EXCL_LINE - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_HELLO); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Request vc hello : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg = NULL; - int result = 0; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_time, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - dbus_message_unref(msg); - - if (NULL != result_msg) { - dbus_message_unref(result_msg); - result = 0; - } else { - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - - -int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_INITIALIZE); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc initialize : Fail to make message "); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Receive the reply for initializing"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != result_msg) { - int tmp = -1; - int tmp_service_state = 0; - int tmp_daemon_pid = 0; - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp, - DBUS_TYPE_INT32, &tmp_service_state, - DBUS_TYPE_INT32, &tmp_daemon_pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - - dbus_message_unref(result_msg); - - if (0 == result) { - *mgr_pid = tmp; - *service_state = tmp_service_state; - *daemon_pid = tmp_daemon_pid; - - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Get arguments for initializing"); - - /* add a rule for daemon error */ - char rule[256] = {0, }; - snprintf(rule, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - if (NULL == g_conn_listener) { - if (g_is_connection_opened) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] g_conn_listener is NULL abnormally"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCC, "[INFO] g_conn_listener is NULL and DBUS connection was closed"); - return VC_ERROR_NONE; - } - } - dbus_bus_add_match(g_conn_listener, rule, NULL); - - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : result = %d mgr = %d service = %d daemon_pid = %d", result, *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc initialize : result = %d", result); //LCOV_EXCL_LINE - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL "); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_finalize(int pid) -{ - DBusError err; - dbus_error_init(&err); - - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - /* remove a rule for daemon error */ - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_conn_listener, rule_err, &err); - dbus_connection_flush(g_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_FINALIZE); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc finalize : Fail to make message "); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : pid(%d)", pid); - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc finalize : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL "); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -//LCOV_EXCL_START -int vc_dbus_request_set_exclusive_command(int pid, bool value) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_EXCLUSIVE_CMD); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set exclusive command : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : pid(%d)", pid); - } - - int temp = value; - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &temp, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : result = %d", result); - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -//LCOV_EXCL_STOP - -int vc_dbus_request_set_command(int pid, vc_cmd_type_e cmd_type) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_COMMAND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &cmd_type, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_UNSET_COMMAND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc unset command : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), type(%d)", pid, cmd_type); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &cmd_type, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc unset command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_set_foreground(int pid, bool value) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg = NULL; - int tmp_value = 0; - - tmp_value = (int)value; - - msg = dbus_message_new_signal( - VC_MANAGER_SERVICE_OBJECT_PATH, - VC_MANAGER_SERVICE_INTERFACE, - VCC_MANAGER_METHOD_SET_FOREGROUND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set foreground to manager : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground to manager : client pid(%d), value(%s)", pid, tmp_value ? "true" : "false"); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &tmp_value, - DBUS_TYPE_INVALID); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_message_unref(msg); - - msg = NULL; - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_FOREGROUND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set foreground to daemon : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground to daemon : client pid(%d), value(%s)", pid, tmp_value ? "true" : "false"); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &tmp_value, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCC, "[Dbus DEBUG] Success to Send"); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - return 0; -} - -//LCOV_EXCL_START -int vc_dbus_set_server_dialog(int pid, const char* app_id, const char* credential) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_SERVER_DIALOG); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set server dialog : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s)", pid, app_id); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &app_id, - DBUS_TYPE_STRING, &credential, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set server dialog : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -//LCOV_EXCL_STOP - -int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - } - } - - DBusMessage* msg; - int tmp_continue = 0; - - tmp_continue = (int)continuous; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_DIALOG); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc request dialog to manager : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog to manager : client pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", getpid(), disp_text, utt_text, continuous); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &disp_text, - DBUS_TYPE_STRING, &utt_text, - DBUS_TYPE_INT32, &tmp_continue, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCC, "[Dbus DEBUG] Success to Send"); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return 0; - -//LCOV_EXCL_START -/* - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -*/ -//LCOV_EXCL_STOP -} - -int vc_dbus_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - } - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_IS_SYS_COMMAND_VALID); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc is system command valid : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - int tmp_sys_cmd = 0; - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp_sys_cmd, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - *is_sys_cmd_valid = (bool)tmp_sys_cmd; - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : result = %d, is_sys_cmd_valid = %d", result, *is_sys_cmd_valid); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc is system command valid : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -//LCOV_EXCL_START -#if 0 -int vc_dbus_request_start(int pid, int silence) -{ - DBusMessage* msg; - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_REQUEST_START); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc start : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc start : pid(%d), silence(%d)", pid, silence); - } - - DBusMessageIter args; - dbus_message_iter_init_append(msg, &args); - - /* Append result*/ - dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(pid)); - dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(silence)); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc start : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc start : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_stop(int pid) -{ - DBusMessage* msg; - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_REQUEST_STOP); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc stop : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc stop : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc stop : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc stop : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_cancel(int pid) -{ - DBusMessage* msg; - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */ - VC_SERVER_SERVICE_INTERFACE, /* interface name of the signal */ - VC_METHOD_REQUEST_CANCEL); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -#endif -//LCOV_EXCL_STOP - -//LCOV_EXCL_START -/* Authority */ -int vc_dbus_request_auth_enable(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, /* object name of the signal */ - target_if_name, /* interface name of the signal */ - VC_METHOD_AUTH_ENABLE); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth enable : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth enable : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_disable(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, /* object name of the signal */ - target_if_name, /* interface name of the signal */ - VC_METHOD_AUTH_DISABLE); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth disable : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth disable : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_start(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, - target_if_name, - VC_METHOD_AUTH_START); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth start : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d)", pid); - } - - DBusMessageIter args; - dbus_message_iter_init_append(msg, &args); - - /* Append result*/ - dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(pid)); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth start : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_stop(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, - target_if_name, - VC_METHOD_AUTH_STOP); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth stop : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth stop : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_cancel(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, /* object name of the signal */ - target_if_name, /* interface name of the signal */ - VC_METHOD_AUTH_CANCEL); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth cancel : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth cancel : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -//LCOV_EXCL_STOP - -int vc_dbus_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - int tmp_to_vcm = 0; - - tmp_to_vcm = (int)to_vcm; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_REQUEST_TTS); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc request tts to manager : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts to manager : client pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, text, language, to_vcm); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &text, - DBUS_TYPE_STRING, &language, - DBUS_TYPE_INT32, &tmp_to_vcm, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - int tmp_utt_id = -1; - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp_utt_id, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - *utt_id = tmp_utt_id; - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : result = %d, utt_id = %d", result, *utt_id); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc request tts : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; - - return 0; -} - -int vc_dbus_cancel_tts(int pid, int utt_id) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_CANCEL_TTS); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel tts to manager : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts to manager : client pid(%d), utt_id(%d)", pid, utt_id); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel tts : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; - - return 0; -} - -int vc_dbus_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_GET_TTS_AUDIO_FORMAT); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get tts audio format : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : client pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - int tmp_rate; - int tmp_channel; - int tmp_audio_type; - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp_rate, - DBUS_TYPE_INT32, &tmp_channel, - DBUS_TYPE_INT32, &tmp_audio_type, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - *rate = tmp_rate; - *channel = tmp_channel; - *audio_type = tmp_audio_type; - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : result = %d, rate = %d, channel = %d, audio_type = %d", result, *rate, *channel, *audio_type); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get tts audio format : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; - - return 0; -} - diff --git a/client/vc_dbus.h b/client/vc_dbus.h deleted file mode 100644 index 5d13712..0000000 --- a/client/vc_dbus.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VC_DBUS_H_ -#define __VC_DBUS_H_ - -#include "voice_control_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int vc_dbus_open_connection(); - -int vc_dbus_close_connection(); - - -int vc_dbus_request_hello(); - -int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid); - -int vc_dbus_request_finalize(int pid); - -int vc_dbus_request_set_exclusive_command(int pid, bool value); - -int vc_dbus_request_set_command(int pid, vc_cmd_type_e cmd_type); - -int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type); - -int vc_dbus_set_foreground(int pid, bool value); - -int vc_dbus_set_server_dialog(int pid, const char* app_id, const char* credential); - -int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous); - -int vc_dbus_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid); - -#if 0 -int vc_dbus_request_start(int pid, int silence); - -int vc_dbus_request_stop(int pid); - -int vc_dbus_request_cancel(int pid); -#endif - -/* Authority */ -int vc_dbus_request_auth_enable(int pid, int mgr_pid); - -int vc_dbus_request_auth_disable(int pid, int mgr_pid); - -int vc_dbus_request_auth_start(int pid, int mgr_pid); - -int vc_dbus_request_auth_stop(int pid, int mgr_pid); - -int vc_dbus_request_auth_cancel(int pid, int mgr_pid); - -/* tts feedback */ - -int vc_dbus_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id); - -int vc_dbus_cancel_tts(int pid, int utt_id); - -int vc_dbus_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type); - -#ifdef __cplusplus -} -#endif - -#endif /* __VC_DBUS_H_ */ diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 2a31598..1203bf6 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -32,7 +32,6 @@ #include "vc_main.h" #include "vc_mgr_client.h" #include "vc_mgr_tidl.h" -#include "vc_mgr_dbus.h" #include "vc_mgr_data.h" #include "vc_mgr_player.h" #include "voice_control.h" @@ -47,7 +46,6 @@ static Ecore_Timer* g_send_hello_timer = NULL; static Ecore_Timer* g_request_init_timer = NULL; -static int g_dbus_send_hello_count = 0; static int g_tidl_send_hello_count = 0; static Ecore_Timer* g_m_set_volume_timer = NULL; @@ -331,11 +329,6 @@ static void __vc_mgr_internal_unprepare() SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request finalize : %s", __vc_mgr_get_error_code(ret)); } - ret = vc_mgr_dbus_request_finalize(g_vc_m->handle); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request dbus finalize : %s", __vc_mgr_get_error_code(ret)); - } - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); return; } @@ -580,7 +573,6 @@ int vc_mgr_prepare(void) } if (NULL == g_send_hello_timer) { - g_dbus_send_hello_count = 0; g_tidl_send_hello_count = 0; SLOG(LOG_INFO, TAG_VCM, "[DEBUG] Create a new timer for preparation"); ecore_thread_main_loop_begin(); @@ -4251,7 +4243,7 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e return VC_ERROR_INVALID_STATE; } - int ret = vc_mgr_dbus_send_utterance_status(pid, utt_id, utt_status); + int ret = vc_mgr_tidl_send_utterance_status(pid, utt_id, utt_status); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to send utterance status : %s", __vc_mgr_get_error_code(ret)); else diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c deleted file mode 100644 index c59a3d9..0000000 --- a/client/vc_mgr_dbus.c +++ /dev/null @@ -1,794 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#include "vc_main.h" -#include "vc_mgr_client.h" -#include "vc_mgr_dbus.h" -#include "vc_command.h" - - -static pthread_mutex_t g_m_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; - -static int g_m_waiting_short_time = 200; -static bool g_is_connection_opened = false; - -static Ecore_Fd_Handler* g_m_fd_handler = NULL; - -static DBusConnection* g_m_conn_sender = NULL; -static DBusConnection* g_m_conn_listener = NULL; - -extern int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg); - -extern int __vc_mgr_cb_set_foreground(int pid, bool value); - -extern int __vc_mgr_cb_private_data_requested(const char* key, char** data); - -/* for TTS feedback */ -extern int __vc_mgr_cb_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); - -/* Authority */ -extern int __vc_mgr_request_auth_enable(int pid); - -extern int __vc_mgr_request_auth_disable(int pid); - -extern int __vc_mgr_request_auth_start(int pid); - -extern int __vc_mgr_request_auth_stop(int pid); - -extern int __vc_mgr_request_auth_cancel(int pid); - -// TODO: remove listener event callback -static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_m_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_m_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_m_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - break; - } - - /* SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Message is arrived"); */ - - DBusError err; - dbus_error_init(&err); - - char if_name[64] = {0, }; - snprintf(if_name, 64, "%s", VC_MANAGER_SERVICE_INTERFACE); - - if (dbus_message_is_signal(msg, if_name, VCC_MANAGER_METHOD_SET_FOREGROUND)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground"); - int pid = 0; - int value = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &value, - DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Get arguments error (%s)", err.message); - dbus_error_free(&err); - } - - SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false"); - - __vc_mgr_cb_set_foreground(pid, (bool)value); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VCC_MANAGER_METHOD_SET_FOREGROUND */ - - else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_GET_PRIVATE_DATA)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request get private data"); - int pid = 0; - int ret = -1; - char* key = NULL; - char* temp = NULL; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &key, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (pid > 0) { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request get private data : pid(%d) ", pid); - ret = __vc_mgr_cb_private_data_requested(key, &temp); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr get request get private data : invalid pid "); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &temp, DBUS_TYPE_INVALID); - - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc get request get private data : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc get request get private data : result(%d)", ret); - - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr get request get private data : fail to create reply message"); - } - - if (NULL != temp) free(temp); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VCD_MANAGER_METHOD_GET_PRIVATE_DATA */ - - /* Authority */ - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_ENABLE)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth enable"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth enable : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth enable : pid(%d)", pid); - ret = __vc_mgr_request_auth_enable(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth enable : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth enable : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth enable : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_ENABLE */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_DISABLE)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth disable"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth disable : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth disable : pid(%d)", pid); - ret = __vc_mgr_request_auth_disable(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth disable : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth disable : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth disable : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_DISABLE */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_START)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth start"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth start : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth start : pid(%d)", pid); - ret = __vc_mgr_request_auth_start(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth start : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth start : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth start : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_START */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_STOP)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth stop"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth stop : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth stop : pid(%d)", pid); - ret = __vc_mgr_request_auth_stop(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth stop : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth stop : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth stop : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_STOP */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_CANCEL)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth cancel"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth cancel : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth cancel : pid(%d)", pid); - ret = __vc_mgr_request_auth_cancel(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc request auth cancel : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc request auth cancel : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth cancel : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_CANCEL */ - - else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Owner Changed"); - /* remove a rule for daemon error */ - DBusError err; - /* initialize the error value */ - dbus_error_init(&err); - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_m_conn_listener, rule_err, &err); - dbus_connection_flush(g_m_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); - dbus_error_free(&err); - } - __vc_mgr_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* NameOwnerChanged */ - - else { - const char* sender = dbus_message_get_sender(msg); - const char* destination = dbus_message_get_destination(msg); - const char* path = dbus_message_get_path(msg); - const char* interf = dbus_message_get_interface(msg); - const char* member = dbus_message_get_member(msg); - int type = dbus_message_get_type(msg); - SLOG(LOG_ERROR, TAG_VCM, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } /* while(1) */ - - return ECORE_CALLBACK_PASS_ON; -} - -static void __vc_mgr_dbus_connection_free() -{ - if (NULL != g_m_conn_listener) { - dbus_connection_close(g_m_conn_listener); - dbus_connection_unref(g_m_conn_listener); - g_m_conn_listener = NULL; - } - if (NULL != g_m_conn_sender) { - dbus_connection_close(g_m_conn_sender); - dbus_connection_unref(g_m_conn_sender); - g_m_conn_sender = NULL; - } -} - -int vc_mgr_dbus_open_connection() -{ - pthread_mutex_lock(&g_m_dbus_mutex); - - if (NULL != g_m_conn_sender && NULL != g_m_conn_listener) { - SLOG(LOG_WARN, TAG_VCM, "already existed connection "); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_NONE; - } - - DBusError err; - int ret; - - /* initialize the error value */ - dbus_error_init(&err); - - /* connect to the DBUS system bus, and check for errors */ - g_m_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_m_conn_sender) { - SLOG(LOG_ERROR, TAG_VCM, "Fail to get dbus connection "); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_m_conn_sender, false); - - /* connect to the DBUS system bus, and check for errors */ - g_m_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_m_conn_listener) { - SLOG(LOG_ERROR, TAG_VCM, "Fail to get dbus connection "); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_m_conn_listener, false); - - SLOG(LOG_INFO, TAG_VCM, "service name is %s", VC_MANAGER_SERVICE_NAME); - - /* register our name on the bus, and check for errors */ - ret = dbus_bus_request_name(g_m_conn_listener, VC_MANAGER_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Name Error (%s)", err.message); - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCM, "fail dbus_bus_request_name()"); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != g_m_fd_handler) { - SLOG(LOG_WARN, TAG_VCM, "The handler already exists."); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_NONE; - } - - char rule[128] = {0, }; - snprintf(rule, 128, "type='signal',interface='%s'", VC_MANAGER_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_m_conn_listener, rule, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); - dbus_error_free(&err); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_m_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCM, "fail to get fd from dbus "); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCM, "Get fd from dbus : %d", fd); - } - - g_m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)vc_mgr_listener_event_callback, g_m_conn_listener, NULL, NULL); - - if (NULL == g_m_fd_handler) { - SLOG(LOG_ERROR, TAG_VCM, "fail to get fd handler from ecore "); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - g_is_connection_opened = true; - - pthread_mutex_unlock(&g_m_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCM, "[INFO] manager dbus connection is opened"); - - return VC_ERROR_NONE; -} - -int vc_mgr_dbus_close_connection() -{ - pthread_mutex_lock(&g_m_dbus_mutex); - - DBusError err; - dbus_error_init(&err); - - if (NULL != g_m_fd_handler) { - ecore_main_fd_handler_del(g_m_fd_handler); - g_m_fd_handler = NULL; - } - - if (NULL != g_m_conn_listener) { - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, pid); - - dbus_bus_release_name(g_m_conn_listener, service_name, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - } - - __vc_mgr_dbus_connection_free(); - - g_is_connection_opened = false; - - pthread_mutex_unlock(&g_m_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCM, "[INFO] manager dbus connection is closed"); - - return VC_ERROR_NONE; -} - -int vc_mgr_dbus_reconnect() -{ - if (!g_m_conn_sender || !g_m_conn_listener) { - vc_mgr_dbus_close_connection(); - - if (0 != vc_mgr_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCM, "[DBUS] Reconnect"); - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_m_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_m_conn_listener); - - SLOG(LOG_INFO, TAG_VCM, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); - - if (false == sender_connected || false == listener_connected) { - vc_mgr_dbus_close_connection(); - - if (0 != vc_mgr_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCM, "[DBUS] Reconnect"); - } - - return 0; -} - -static int __dbus_check() -{ - if (NULL == g_m_conn_sender || NULL == g_m_conn_listener) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - return vc_mgr_dbus_reconnect(); - } - return 0; -} - -int vc_mgr_dbus_request_hello() -{ - SLOG(LOG_DEBUG, TAG_VCM, "@@ Request vc hello start"); - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_HELLO); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCM, "@@ Request vc hello : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg = NULL; - int result = 0; - - result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, g_m_waiting_short_time, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - dbus_message_unref(msg); - - if (NULL != result_msg) { - dbus_message_unref(result_msg); - result = 0; - } else { - result = VC_ERROR_TIMED_OUT; - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@ Request vc hello end"); - return result; -} - -static int __dbus_restore_daemon() -{ - int ret = -1; - int count = 0; - while (0 != ret) { - ret = vc_mgr_dbus_request_hello(); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon"); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry restore daemon"); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_ERROR, TAG_VCM, "[SUCCESS] restore daemon"); - } - } - return ret; -} - -int vc_mgr_dbus_request_finalize(int pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - bool exist = dbus_bus_name_has_owner(g_m_conn_sender, VC_SERVER_SERVICE_NAME, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - int ret; - if (false == exist) { - ret = __dbus_restore_daemon(); - if (VC_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon"); - return VC_ERROR_TIMED_OUT; - } - return VC_ERROR_OPERATION_FAILED; - } - - /* remove a rule for daemon error */ - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_m_conn_listener, rule_err, &err); - dbus_connection_flush(g_m_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); - dbus_error_free(&err); - return VC_ERROR_OPERATION_FAILED; - } - - return VC_ERROR_NONE; -} - -static DBusMessage* __get_message(int pid, const char* method, int type) -{ - char service_name[64]; - char object_path[64]; - char target_if_name[128]; - - memset(service_name, '\0', 64); - memset(object_path, '\0', 64); - memset(target_if_name, '\0', 128); - - if (VC_COMMAND_TYPE_FOREGROUND == type || VC_COMMAND_TYPE_BACKGROUND == type) { - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - snprintf(object_path, 64, "%s", VC_CLIENT_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - } else if (VC_COMMAND_TYPE_WIDGET == type) { - snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); - snprintf(object_path, 64, "%s", VC_WIDGET_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_WIDGET_SERVICE_INTERFACE, pid); - } else { - return NULL; - } - - SLOG(LOG_INFO, TAG_VCM, "[Dbus] Service(%s) object(%s) if(%s)", service_name, object_path, target_if_name); - - return dbus_message_new_method_call(service_name, object_path, target_if_name, method); -} - -// int vc_mgr_dbus_send_result(int pid, int cmd_type, int result_id) -// { -// if (0 != __dbus_check()) { -// return VC_ERROR_OPERATION_FAILED; -// } - -// DBusMessage* msg = NULL; - -// switch (cmd_type) { -// case VC_COMMAND_TYPE_FOREGROUND: -// case VC_COMMAND_TYPE_BACKGROUND: -// msg = __get_message(pid, VCD_METHOD_RESULT, cmd_type); -// break; -// case VC_COMMAND_TYPE_WIDGET: -// msg = __get_message(pid, VCD_WIDGET_METHOD_RESULT, cmd_type); -// break; -// default: -// SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Command type is NOT valid(%d)", cmd_type); -// return -1; -// } - -// if (NULL == msg) -// SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Message is NULL"); - -// dbus_message_append_args(msg, DBUS_TYPE_INT32, &result_id, DBUS_TYPE_INVALID); - -// dbus_message_set_no_reply(msg, TRUE); - -// /* send the message and flush the connection */ -// if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) { -// SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send"); -// dbus_message_unref(msg); -// return VC_ERROR_OPERATION_FAILED; -// } else { -// SLOG(LOG_INFO, TAG_VCM, "[Dbus] SUCCESS Send"); -// dbus_connection_flush(g_m_conn_sender); -// } - -// dbus_message_unref(msg); -// return 0; -// } - -int vc_mgr_dbus_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - msg = __get_message(pid, VC_MANAGER_METHOD_UTTERANCE_STATUS, VC_COMMAND_TYPE_FOREGROUND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc send utterance status : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &utt_status, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - /* send the message and flush the connection */ - if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send"); - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCM, "[Dbus] SUCCESS Send"); - dbus_connection_flush(g_m_conn_sender); - } - - dbus_message_unref(msg); - return 0; -} \ No newline at end of file diff --git a/client/vc_mgr_dbus.h b/client/vc_mgr_dbus.h deleted file mode 100644 index 4c82e19..0000000 --- a/client/vc_mgr_dbus.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VC_DBUS_H_ -#define __VC_DBUS_H_ - -#include "voice_control_manager_internal.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -int vc_mgr_dbus_open_connection(); - -int vc_mgr_dbus_close_connection(); - - -int vc_mgr_dbus_request_hello(); - -int vc_mgr_dbus_request_finalize(int pid); - -int vc_mgr_dbus_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status); - -#ifdef __cplusplus -} -#endif - -#endif /* __VC_DBUS_H_ */ diff --git a/client/vc_setting.c b/client/vc_setting.c index c415a77..1e99383 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -17,7 +17,6 @@ #include "vc_config_mgr.h" #include "vc_main.h" -// #include "vc_setting_dbus.h" #include "vc_setting_tidl.h" #include "voice_control_common.h" #include "voice_control_setting.h" diff --git a/client/vc_setting_dbus.c b/client/vc_setting_dbus.c deleted file mode 100644 index c249d40..0000000 --- a/client/vc_setting_dbus.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "vc_setting_dbus.h" -#include "vc_main.h" - - -static int g_s_waiting_time = 3000; - -static Ecore_Fd_Handler* g_s_fd_handler = NULL; - -static DBusConnection* g_s_conn_sender = NULL; -static DBusConnection* g_s_conn_listener = NULL; - - -static Eina_Bool listener_setting_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_s_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_s_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_s_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - break; - } - - DBusError err; - dbus_error_init(&err); - - char if_name[64] = {0, }; - snprintf(if_name, 64, "%s", VC_SETTING_SERVICE_INTERFACE); - - if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_HELLO)) { - SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get Hello"); - int pid = 0; - int response = -1; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (pid > 0) { - SLOG(LOG_DEBUG, TAG_VCS, "@@ vc get hello : pid(%d) ", pid); - response = 1; - } else { - SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : invalid pid "); - } - - DBusMessage* reply = NULL; - 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_s_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : fail to send reply"); - else - SLOG(LOG_DEBUG, TAG_VCS, "@@ vc get hello : result(%d)", response); - - dbus_connection_flush(g_s_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - } /* VCD_METHOD_HELLO */ - - else { - SLOG(LOG_DEBUG, TAG_VCS, "Message is NOT valid"); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } /* while(1) */ - - return ECORE_CALLBACK_PASS_ON; -} - -static void __vc_setting_dbus_connection_free() -{ - if (NULL != g_s_conn_listener) { - dbus_connection_close(g_s_conn_listener); - dbus_connection_unref(g_s_conn_listener); - g_s_conn_listener = NULL; - } - if (NULL != g_s_conn_sender) { - dbus_connection_close(g_s_conn_sender); - dbus_connection_unref(g_s_conn_sender); - g_s_conn_sender = NULL; - } -} - -int vc_setting_dbus_open_connection() -{ - if (NULL != g_s_conn_sender && NULL != g_s_conn_listener) { - SLOG(LOG_WARN, TAG_VCS, "already existed connection "); - return 0; - } - - DBusError err; - int ret; - - /* initialize the error value */ - dbus_error_init(&err); - - /* connect to the DBUS system bus, and check for errors */ - g_s_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_s_conn_sender) { - SLOG(LOG_ERROR, TAG_VCS, "Fail to get dbus connection "); - return VC_ERROR_OPERATION_FAILED; - } - - g_s_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_s_conn_listener) { - SLOG(LOG_ERROR, TAG_VCS, "Fail to get dbus connection "); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } - - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_SETTING_SERVICE_NAME, pid); - - SLOG(LOG_DEBUG, TAG_VCS, "service name is %s", service_name); - - /* register our name on the bus, and check for errors */ - ret = dbus_bus_request_name(g_s_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Name Error (%s)", err.message); - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCS, "fail dbus_bus_request_name()"); - __vc_setting_dbus_connection_free(); - return -2; - } - - if (NULL != g_s_fd_handler) { - SLOG(LOG_WARN, TAG_VCS, "The handler already exists."); - __vc_setting_dbus_connection_free(); - return 0; - } - - char rule[128] = {0, }; - snprintf(rule, 128, "type='signal',interface='%s'", VC_SETTING_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_s_conn_listener, rule, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Match Error (%s)", err.message); - dbus_error_free(&err); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } - - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_s_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCS, "fail to get fd from dbus "); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCS, "Get fd from dbus : %d", fd); - } - - g_s_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_setting_event_callback, g_s_conn_listener, NULL, NULL); - if (NULL == g_s_fd_handler) { - SLOG(LOG_ERROR, TAG_VCS, "fail to get fd handler from ecore "); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } - - return 0; -} - -int vc_setting_dbus_close_connection() -{ - DBusError err; - dbus_error_init(&err); - - if (NULL != g_s_fd_handler) { - ecore_main_fd_handler_del(g_s_fd_handler); - g_s_fd_handler = NULL; - } - - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_SETTING_SERVICE_NAME, pid); - - char rule[128] = {0, }; - snprintf(rule, 128, "type='signal',interface='%s'", VC_SETTING_SERVICE_INTERFACE); - dbus_bus_remove_match(g_s_conn_listener, rule, NULL); - - dbus_bus_release_name(g_s_conn_listener, service_name, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - __vc_setting_dbus_connection_free(); - - return 0; -} - -int vc_setting_dbus_reconnect() -{ - if (!g_s_conn_sender || !g_s_conn_listener) { - vc_setting_dbus_close_connection(); - - if (0 != vc_setting_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCS, "[DBUS] Reconnect"); - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_s_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_s_conn_listener); - SLOG(LOG_WARN, TAG_VCS, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); - - if (false == sender_connected || false == listener_connected) { - vc_setting_dbus_close_connection(); - - if (0 != vc_setting_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCS, "[DBUS] Reconnect"); - } - - return 0; -} - -int vc_setting_dbus_request_hello() -{ - if (NULL == g_s_conn_sender) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_HELLO); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCS, "@@ Request vc hello : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg = NULL; - int result = 0; - - result_msg = dbus_connection_send_with_reply_and_block(g_s_conn_sender, msg, 500, &err); - - if (dbus_error_is_set(&err)) { - dbus_error_free(&err); - } - - dbus_message_unref(msg); - - if (NULL != result_msg) { - dbus_message_unref(result_msg); - result = 0; - } else { - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_setting_dbus_request_set_language(int pid, const char* language) -{ - if (NULL == g_s_conn_sender) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus does not open"); - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_SETTING_METHOD_SET_LANGUAGE); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCS, "@@ vc set language : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCS, "@@ vc set language : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &language, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_s_conn_sender, msg, g_s_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - SLOG(LOG_DEBUG, TAG_VCS, "@@ vcd set language : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCS, "@@ Result message is NULL"); - vc_setting_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} diff --git a/client/vc_setting_dbus.h b/client/vc_setting_dbus.h deleted file mode 100644 index 3404d4f..0000000 --- a/client/vc_setting_dbus.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VC_SETTING_DBUS_H_ -#define __VC_SETTING_DBUS_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -int vc_setting_dbus_open_connection(); - -int vc_setting_dbus_close_connection(); - -int vc_setting_dbus_request_hello(); - -int vc_setting_dbus_request_set_language(int pid, const char* language); - -#ifdef __cplusplus -} -#endif - -#endif /* __VC_SETTING_DBUS_H_ */ diff --git a/common/vc_main.h b/common/vc_main.h index 00e079a..6b6d400 100644 --- a/common/vc_main.h +++ b/common/vc_main.h @@ -18,7 +18,6 @@ #ifndef __VC_MAIN_H_ #define __VC_MAIN_H_ -#include #include #include #include diff --git a/include/voice-control-engine.pc.in b/include/voice-control-engine.pc.in index d089851..6dd2e26 100644 --- a/include/voice-control-engine.pc.in +++ b/include/voice-control-engine.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@_engine Description: Voice control engine header -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@_engine Cflags: -I${includedir} diff --git a/include/voice-control-manager.pc.in b/include/voice-control-manager.pc.in index 5165ffe..547af8e 100644 --- a/include/voice-control-manager.pc.in +++ b/include/voice-control-manager.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@_manager Description: Voice control manager client library -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@_manager Cflags: -I${includedir} diff --git a/include/voice-control-widget.pc.in b/include/voice-control-widget.pc.in index 308394a..4af9614 100644 --- a/include/voice-control-widget.pc.in +++ b/include/voice-control-widget.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@_widget Description: Voice control library for widget -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@_widget Cflags: -I${includedir} diff --git a/include/voice-control.pc.in b/include/voice-control.pc.in index 8396172..1f96496 100644 --- a/include/voice-control.pc.in +++ b/include/voice-control.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@ Description: Voice control client library -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@ Cflags: -I${includedir} diff --git a/org.tizen.voice.vcserver.service b/org.tizen.voice.vcserver.service deleted file mode 100644 index aa51fd1..0000000 --- a/org.tizen.voice.vcserver.service +++ /dev/null @@ -1,5 +0,0 @@ -[D-BUS Service] -Name=org.tizen.voice.vcserver -#Exec=/usr/bin/vc-daemon -#Exec=/bin/sh -c "launch_app org.tizen.vc-engine-default" -Exec=/bin/sh -c "vc_getengine get system db/voice/vc/engine/default | awk '{print$5}' | xargs -t -i launch_app {}" diff --git a/org.tizen.voice.vcserver.tv.service b/org.tizen.voice.vcserver.tv.service deleted file mode 100644 index 22b0781..0000000 --- a/org.tizen.voice.vcserver.tv.service +++ /dev/null @@ -1,4 +0,0 @@ -[D-BUS Service] -Name=org.tizen.voice.vcserver -#Exec=/usr/bin/vc-daemon -Exec=/bin/sh -c "launch_app org.tizen.voice-client" diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 7ee6ece..952b983 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -20,7 +20,6 @@ BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-session) -BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) @@ -231,10 +230,8 @@ mkdir -p %{_libdir}/voice/vc %{_bindir}/vc_getengine %{TZ_SYS_RO_SHARE}/voice/vc/1.0/vc-config.xml %{TZ_SYS_RO_SHARE}/voice/vc/1.0/dependency-audio-manager/libvc-audio-manager.so -%{TZ_SYS_RO_SHARE}/dbus-1/services/org.tizen.voice* %{TZ_SYS_RO_SHARE}/parser-plugins/voice-control.info %{TZ_SYS_RO_ETC}/package-manager/parserlib/metadata/libvc-engine-parser.so* -/etc/dbus-1/session.d/vc-server.conf %files devel %manifest %{name}-devel.manifest diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 65e8713..399781c 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -9,8 +9,6 @@ SET(SRCS vcd_client_data.c vcd_server_data.cpp vcd_config.c -# vcd_dbus_server.c -# vcd_dbus.c vcd_tidl.c vcd_stub.c vcd_mgr_stub.c diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c deleted file mode 100644 index b03d102..0000000 --- a/server/vcd_dbus.c +++ /dev/null @@ -1,546 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include -#include "vcd_client_data.h" -// #include "vcd_dbus.h" -// #include "vcd_dbus_server.h" -#include "vcd_tidl.h" -#include "vcd_main.h" - - -static DBusConnection* g_conn_sender = NULL; -static DBusConnection* g_conn_listener = NULL; - -static Ecore_Fd_Handler* g_dbus_fd_handler = NULL; - -// static int g_waiting_time = 3000; - -// static int g_volume_count = 0; - - -// static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e type) -// { -// char service_name[64] = {0,}; -// char object_path[64] = {0,}; -// char target_if_name[128] = {0,}; - -// if (VCD_CLIENT_TYPE_NORMAL == type) { -// snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); -// snprintf(object_path, 64, "%s", VC_CLIENT_SERVICE_OBJECT_PATH); -// snprintf(target_if_name, 128, "%s", VC_CLIENT_SERVICE_INTERFACE); -// } else if (VCD_CLIENT_TYPE_WIDGET == type) { -// snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); -// snprintf(object_path, 64, "%s", VC_WIDGET_SERVICE_OBJECT_PATH); -// snprintf(target_if_name, 128, "%s", VC_WIDGET_SERVICE_INTERFACE); -// } else if (VCD_CLIENT_TYPE_MANAGER == type) { -// snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); -// snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); -// snprintf(target_if_name, 128, "%s", VC_MANAGER_SERVICE_INTERFACE); -// } else { -// return NULL; -// } - -// return dbus_message_new_method_call(service_name, object_path, target_if_name, method); -// } - -int vcd_dbus_reconnect() -{ - if (!g_conn_sender || !g_conn_listener) { - vcd_dbus_close_connection(); - - if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCD, "[DBUS] Reconnect"); - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); - SLOG(LOG_WARN, TAG_VCD, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); - - if (false == sender_connected || false == listener_connected) { - vcd_dbus_close_connection(); - - if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCD, "[DBUS] Reconnect"); - } - - return 0; -} - -// static int __dbus_check() -// { -// if (NULL == g_conn_sender || NULL == g_conn_listener) { -// SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection"); -// return vcd_dbus_reconnect(); -// } -// return 0; -// } - -int vcd_check_dbus_connection() -{ - if (NULL == g_conn_sender || NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection sender(%p), listener(%p)", g_conn_sender, g_conn_listener); - return -1; - } - return 0; -} - -/* -int vcdc_send_manager_pid(int manager_pid) -{ - DBusError err; - dbus_error_init(&err); - - DBusMessage* msg = NULL; - - // Send to client - msg = dbus_message_new_signal( - VC_CLIENT_SERVICE_OBJECT_PATH, - VC_CLIENT_SERVICE_INTERFACE, - VCD_METHOD_SEND_MANAGER_PID); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &manager_pid, DBUS_TYPE_INVALID); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "@@ Send manager pid to client : pid(%d)", manager_pid); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return 0; -} - -int vcdc_send_error_signal(int reason, char *err_msg) -{ - SLOG(LOG_ERROR, TAG_VCD, "@@ Send error signal"); - - if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Input parameter is NULL"); - return VCD_ERROR_INVALID_PARAMETER; - } - - if (0 != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - int daemon_pid; - DBusError err; - dbus_error_init(&err); - - DBusMessage* msg = NULL; - - // msg = dbus_message_new_signal( - // VC_MANAGER_SERVICE_OBJECT_PATH, - // VC_MANAGER_SERVICE_INTERFACE, - // VCD_MANAGER_METHOD_ERROR); - - // if (NULL == msg) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - // return VCD_ERROR_OUT_OF_MEMORY; - // } - - // daemon_pid = getpid(); - // dbus_message_append_args(msg, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INT32, &daemon_pid, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - // if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - // return VCD_ERROR_OPERATION_FAILED; - // } else { - // SLOG(LOG_INFO, TAG_VCD, "@@ Send error signal to manager: reason(%d), daemon_pid(%d), Error Msg(%s)", reason, daemon_pid, err_msg); - // dbus_connection_flush(g_conn_sender); - // } - - // dbus_message_unref(msg); - - // msg = NULL; - - vcdc_tidl_send_error(reason, err_msg); - - msg = dbus_message_new_signal( - VC_CLIENT_SERVICE_OBJECT_PATH, - VC_CLIENT_SERVICE_INTERFACE, - VCD_METHOD_ERROR); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INT32, &daemon_pid, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "@@ Send error signal : reason(%d), daemon_pid(%d), Error Msg(%s)", reason, daemon_pid, err_msg); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - // msg = NULL; - // msg = dbus_message_new_signal( - // VC_WIDGET_SERVICE_OBJECT_PATH, - // VC_WIDGET_SERVICE_INTERFACE, - // VCD_WIDGET_METHOD_ERROR); - - // if (NULL == msg) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - // return VCD_ERROR_OUT_OF_MEMORY; - // } - - // dbus_message_append_args(msg, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INT32, &daemon_pid, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - // if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - // return VCD_ERROR_OPERATION_FAILED; - // } else { - // SLOG(LOG_INFO, TAG_VCD, "@@ Send error signal to widget : reason(%d), daemon_pid(%d), Error Msg(%s)", reason, daemon_pid, err_msg); - // dbus_connection_flush(g_conn_sender); - // } - - // dbus_message_unref(msg); - - return 0; -} - -int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) -{ - if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Input parameter is NULL"); - return VCD_ERROR_INVALID_PARAMETER; - } - - if (VCD_ERROR_NONE != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - SLOG(LOG_ERROR, TAG_VCD, "@@ Send error to app(%d)", pid); - - DBusMessage* msg = __get_message(pid, VCD_METHOD_ERROR_TO_APP, VCD_CLIENT_TYPE_NORMAL); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &reason, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - if (TRUE != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - dbus_message_unref(msg); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "@@ Send error to app: pid(%d), reason(%d), Error Msg(%s)", pid, reason, err_msg); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return VCD_ERROR_NONE; -} -*/ -/* -int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) -{ - SLOG(LOG_INFO, TAG_VCD, "[Dbus] Send TTS feedback streaming : pid(%d), utt_id(%d), feedback event(%d), buffer(%p), length(%d)", pid, utt_id, event, buffer, len); - - if (0 != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - // make dbus message - DBusMessage* msg = NULL; - msg = __get_message(pid, VCD_METHOD_FEEDBACK_STREAMING, VCD_CLIENT_TYPE_NORMAL); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &event, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &buffer, len, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - int ret = VCD_ERROR_NONE; - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[Dbus] SUCCESS Send"); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return ret; -} -*/ -static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - SLOG(LOG_INFO, TAG_VCD, "@@@ no Dbus message anymore"); - break; - } - - /* Common event */ - if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_HELLO)) - vcd_dbus_server_hello(g_conn_listener, msg); - - /* client event */ - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_INITIALIZE)) - vcd_dbus_server_initialize(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_FINALIZE)) - vcd_dbus_server_finalize(g_conn_listener, msg); -#if 0 - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_EXCLUSIVE_CMD)) - vcd_dbus_server_set_exclusive_command(g_conn_listener, msg); -#endif - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_COMMAND)) - vcd_dbus_server_set_command(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_UNSET_COMMAND)) - vcd_dbus_server_unset_command(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_FOREGROUND)) - vcd_dbus_server_set_foreground(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_SERVER_DIALOG)) - vcd_dbus_server_set_server_dialog(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_DIALOG)) - vcd_dbus_server_dialog(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_IS_SYS_COMMAND_VALID)) - vcd_dbus_server_is_system_command_valid(g_conn_listener, msg); - -#if 0 - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_START)) - vcd_dbus_server_start_request(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_STOP)) - vcd_dbus_server_stop_request(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_CANCEL)) - vcd_dbus_server_cancel_request(g_conn_listener, msg); -#endif - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_SETTING_METHOD_SET_LANGUAGE)) - vcd_dbus_server_set_language(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_TTS)) - vcd_dbus_server_request_tts(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_CANCEL_TTS)) - vcd_dbus_server_cancel_tts(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_GET_TTS_AUDIO_FORMAT)) - vcd_dbus_server_get_tts_audio_format(g_conn_listener, msg); - - else { - const char* sender = dbus_message_get_sender(msg); - const char* destination = dbus_message_get_destination(msg); - const char* path = dbus_message_get_path(msg); - const char* interf = dbus_message_get_interface(msg); - const char* member = dbus_message_get_member(msg); - int type = dbus_message_get_type(msg); - SLOG(LOG_ERROR, TAG_VCD, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } - - return ECORE_CALLBACK_RENEW; -} - -static void __vcd_dbus_connection_free() -{ - if (NULL != g_conn_listener) { - dbus_connection_close(g_conn_listener); - dbus_connection_unref(g_conn_listener); - g_conn_listener = NULL; - } - if (NULL != g_conn_sender) { - dbus_connection_close(g_conn_sender); - dbus_connection_unref(g_conn_sender); - g_conn_sender = NULL; - } -} - -int vcd_dbus_open_connection() -{ - DBusError err; - dbus_error_init(&err); - - int ret; - - /* Create connection for sender */ - g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); - dbus_error_free(&err); - } - - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to get dbus connection"); - return VCD_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_sender, false); - - /* connect to the bus and check for errors */ - g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); - dbus_error_free(&err); - } - - if (NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to get dbus connection"); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_listener, false); - - /* request our name on the bus and check for errors */ - ret = dbus_bus_request_name(g_conn_listener, VC_SERVER_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - printf("Fail to be primary owner in dbus request."); - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to be primary owner"); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_request_name() : %s", err.message); - dbus_error_free(&err); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - /* Flush messages which are received before fd event handler registration */ - while (DBUS_DISPATCH_COMPLETE != dbus_connection_get_dispatch_status(g_conn_listener)) { - SLOG(LOG_INFO, TAG_VCD, "Dbus data is remained, g_conn_listener(%p)", g_conn_listener); - listener_event_callback(NULL, NULL); - } - - /* add fd handler to receive dbus metohd */ - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCD, "fail to get fd from dbus "); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "Get fd from dbus : %d", fd); - } - - g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL); - - if (NULL == g_dbus_fd_handler) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to get fd handler"); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - /* add a rule for getting signal */ - char rule[128]; - snprintf(rule, 128, "type='signal',interface='%s'", VC_SERVER_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_conn_listener, rule, &err);/* see signals from the given interface */ - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_add_match() : %s", err.message); - dbus_error_free(&err); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to open dbus connection"); - - return 0; -} - -int vcd_dbus_close_connection() -{ - DBusError err; - dbus_error_init(&err); - - if (NULL != g_dbus_fd_handler) { - ecore_main_fd_handler_del(g_dbus_fd_handler); - g_dbus_fd_handler = NULL; - } - - if (NULL != g_conn_listener) { - dbus_bus_release_name(g_conn_listener, VC_SERVER_SERVICE_NAME, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_release_name() : %s", err.message); - dbus_error_free(&err); - } - } - __vcd_dbus_connection_free(); - - return 0; -} diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h deleted file mode 100644 index 88fd974..0000000 --- a/server/vcd_dbus.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VCD_DBUS_h__ -#define __VCD_DBUS_h__ - -#include "vcd_main.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int vcd_dbus_open_connection(); - -int vcd_dbus_close_connection(); - -int vcd_check_dbus_connection(); - - -#ifdef __cplusplus -} -#endif - -#endif /* __VCD_DBUS_h__ */ diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c deleted file mode 100644 index 4556102..0000000 --- a/server/vcd_dbus_server.c +++ /dev/null @@ -1,1469 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#include "vcd_client_data.h" -// #include "vcd_dbus.h" -#include "vcd_tidl.h" -// #include "vcd_dbus_server.h" -#include "vcd_main.h" -#include "vcd_server.h" -#include "vcd_config.h" - -vc_cmd_type_e vc_command_types[7] = {VC_COMMAND_TYPE_NONE, - VC_COMMAND_TYPE_FOREGROUND, - VC_COMMAND_TYPE_BACKGROUND, - VC_COMMAND_TYPE_WIDGET, - VC_COMMAND_TYPE_SYSTEM, - VC_COMMAND_TYPE_SYSTEM_BACKGROUND, - VC_COMMAND_TYPE_EXCLUSIVE}; - - -int __dbus_error_return(DBusConnection* conn, DBusMessage* msg, int ret) -{ - 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_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg) -{ - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Hello"); - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -/* for TTS feedback */ -int vcd_dbus_server_mgr_start_feedback(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager start TTS feedback"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] vcd mgr start TTS feedback : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[DEBUG] vcd mgr start TTS feedback : pid(%d)", pid); - ret = vcd_server_mgr_start_feedback(); - } - - 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_INFO, TAG_VCD, "[SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Out of Memory"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_mgr_stop_feedback(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager stop TTS feedback"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] vcd mgr stop TTS feedback : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[DEBUG] vcd mgr stop TTS feedback : pid(%d)", pid); - ret = vcd_server_mgr_stop_feedback(); - } - - 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_INFO, TAG_VCD, "[SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Out of Memory"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_mgr_send_audio_streaming(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - int event = 0; - char* buffer = NULL; - unsigned int len = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send audio streaming"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &event, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &buffer, &len, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr send audio streaming : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send audio streaming : pid(%d), event(%d), buffer(%p), len(%d)", pid, event, buffer, len); - ret = vcd_server_mgr_send_audio_streaming(pid, event, buffer, len); - } - - return ret; -} - -int vcd_dbus_server_mgr_change_system_volume(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - int volume_event = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager change system volume"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &volume_event, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr disable command type : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr change system volume: pid(%d), volume_event(%d)", pid, volume_event); - ret = vcd_server_mgr_change_system_volume(pid, volume_event); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; - -} - -int vcd_dbus_server_mgr_set_audio_streaming_mode(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int mode; - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &mode, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set audio streaming mode"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr set audio streaming mode : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio streaming mode : pid(%d) mode(%d)", pid, mode); - vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)mode); - } - return 0; -} - -/* -* Dbus Server functions for client -*/ -int vcd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int service_state = 0; - int daemon_pid; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Initialize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd initialize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - ret = vcd_server_initialize(pid); - service_state = vcd_server_get_service_state(); - daemon_pid = getpid(); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, daemon_pid); - } - - int mgr_pid = vcd_client_manager_get_pid(); - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &mgr_pid, - DBUS_TYPE_INT32, &service_state, - DBUS_TYPE_INT32, &daemon_pid, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Finalize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd finalize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd finalize : pid(%d)", pid); - ret = vcd_server_finalize(pid); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -#if 0 -int vcd_dbus_server_set_exclusive_command(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int value; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &value, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set exclusive command"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd unset command : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd unset command : pid(%d) value(%d)", pid, value); - ret = vcd_server_set_exclusive_command(pid, (bool)value); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} -#endif - -int vcd_dbus_server_set_command(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int cmd_type; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &cmd_type, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set command"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd set command : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set command : pid(%d), cmd_type(%d)", pid, cmd_type); - ret = vcd_server_set_command(pid, (vc_cmd_type_e)cmd_type); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_unset_command(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int cmd_type; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &cmd_type, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD unset command"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd unset command : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd unset command : pid(%d), cmd_type(%d)", pid, cmd_type); - ret = vcd_server_unset_command(pid, (vc_cmd_type_e)cmd_type); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_set_foreground(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int value; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &value, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set foreground"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd set foreground : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - bool tmp_value; - tmp_value = (bool)value; - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d), value(%s)", pid, value ? "true" : "false"); - vcd_server_set_foreground(pid, tmp_value); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_set_server_dialog(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = -1; - char* app_id = NULL; - char* credential = NULL; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &app_id, - DBUS_TYPE_STRING, &credential, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set server dialog"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd set server dialog : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set server dialog : pid(%d), app_id(%s)", pid, app_id); - ret = vcd_server_set_server_dialog(pid, app_id, credential); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; - -} - -int vcd_dbus_server_dialog(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - char* disp_text = NULL; - char* utt_text = NULL; - int continuous; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &disp_text, - DBUS_TYPE_STRING, &utt_text, - DBUS_TYPE_INT32, &continuous, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request dialog"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd request dialog : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); - ret = vcd_server_dialog(pid, disp_text, utt_text, continuous); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to dialog"); - } - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_is_system_command_valid(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int is_sys_cmd_valid; - - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request to check system command is valid"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd request to check system command is valid : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd dialog : pid(%d)", pid); - ret = vcd_server_is_system_command_valid(pid, &is_sys_cmd_valid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &is_sys_cmd_valid, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d), is_sys_cmd_valid (%d)", ret, is_sys_cmd_valid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -#if 0 -int vcd_dbus_server_start_request(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int silence; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Request Start"); - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &silence, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd start : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd request start : pid(%d), silence(%d)", pid, silence); - ret = vcd_server_request_start(pid, (bool)silence); - } - - 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_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_stop_request(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Request Stop"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd stop : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd request stop : pid(%d)", pid); - ret = vcd_server_request_stop(pid); - } - - 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_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_cancel_request(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Request Cancel"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd cancel : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd request cancel : pid(%d)", pid); - ret = vcd_server_request_cancel(pid); - } - - 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_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} -#endif - -/* -* Dbus Widget-Daemon Server -*/ -int vcd_dbus_server_widget_initialize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int service_state = 0; - int daemon_pid; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Initialize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget initialize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - ret = vcd_server_widget_initialize(pid); - service_state = vcd_server_get_service_state(); - daemon_pid = getpid(); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget initialize : pid(%d) daemon_pid(%d)", pid, daemon_pid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &service_state, - DBUS_TYPE_INT32, &daemon_pid, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_finalize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Finalize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget finalize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); - ret = vcd_server_widget_finalize(pid); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_start_recording(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - int widget_command; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &widget_command, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget start recording"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget start recording : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start recording : pid(%d)", pid); - ret = vcd_server_widget_start_recording(pid, widget_command); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_start(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int silence; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget start"); - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &silence, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd start : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start : pid(%d), silence(%d)", pid, silence); - ret = vcd_server_widget_start(pid, (bool)silence); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_stop(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget stop"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget stop : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget stop : pid(%d)", pid); - ret = vcd_server_widget_stop(pid); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_cancel(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget cancel"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget cancel : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); - ret = vcd_server_widget_cancel(pid); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int enable; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &enable, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget enable asr result"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget enable asr result : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget enable asr result : pid(%d) enable(%d)", pid, enable); - ret = vcd_server_widget_enable_asr_result(pid, enable); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_set_language(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - char* language; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &language, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD server set language"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd server set language : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd server set language : language(%s)", language); - ret = vcd_server_set_language(language); - } - - 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_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_request_tts(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - char* text = NULL; - char* language = NULL; - int to_vcm; - int utt_id = -1; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &text, - DBUS_TYPE_STRING, &language, - DBUS_TYPE_INT32, &to_vcm, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request tts"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd request tts : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d)", pid, text, language, to_vcm); - ret = vcd_server_request_tts(pid, text, language, to_vcm, &utt_id); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d), utt_id(%d)", ret, utt_id); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_cancel_tts(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int utt_id; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD cancel tts"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd cancel tts : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd cancel tts : pid(%d), utt_id(%d)", pid, utt_id); - ret = vcd_server_cancel_tts(pid, utt_id); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_get_tts_audio_format(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int rate; - int channel; - int audio_type; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request tts"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd get tts audio format : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd get tts audio format : pid(%d)", pid); - ret = vcd_server_get_tts_audio_format(pid, &rate, &channel, &audio_type); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &rate, - DBUS_TYPE_INT32, &channel, - DBUS_TYPE_INT32, &audio_type, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} diff --git a/server/vcd_dbus_server.h b/server/vcd_dbus_server.h deleted file mode 100644 index 0d0ec0a..0000000 --- a/server/vcd_dbus_server.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VCD_DBUS_SERVER_h__ -#define __VCD_DBUS_SERVER_h__ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -int vcd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg); - -/* -* Dbus Server functions for manager -*/ -/* for TTS feedback */ -int vcd_dbus_server_mgr_start_feedback(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_mgr_stop_feedback(DBusConnection* conn, DBusMessage* msg); - -/* for Multi-assistant */ -int vcd_dbus_server_mgr_send_audio_streaming(DBusConnection* conn, DBusMessage* msg); - - -/* -* Dbus Server functions for client -*/ - -int vcd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg); - -#if 0 -int vcd_dbus_server_set_exclusive_command(DBusConnection* conn, DBusMessage* msg); -#endif - -int vcd_dbus_server_set_command(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_unset_command(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_set_foreground(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_set_server_dialog(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_dialog(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_is_system_command_valid(DBusConnection* conn, DBusMessage* msg); - -#if 0 -int vcd_dbus_server_start_request(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_stop_request(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_cancel_request(DBusConnection* conn, DBusMessage* msg); -#endif - -/* -* Dbus Server functions for widget -*/ -int vcd_dbus_server_widget_initialize(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_finalize(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_start_recording(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_start(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_stop(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_cancel(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_set_language(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_request_tts(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_cancel_tts(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_get_tts_audio_format(DBusConnection* conn, DBusMessage* msg); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __VCD_DBUS_SERVER_h__ */ diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 7b89164..2d5bcf2 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -23,7 +23,6 @@ #include "vcd_engine_agent.h" #include "vcd_main.h" #include "vcd_recorder.h" -// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vce_internal.h" diff --git a/server/vcd_server.c b/server/vcd_server.c index a4badcf..d82b10b 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -28,7 +28,6 @@ #include "vcd_engine_agent.h" #include "vcd_config.h" #include "vcd_recorder.h" -// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vce_internal.h" diff --git a/server/vce.c b/server/vce.c index e4b359b..9a66d2d 100644 --- a/server/vce.c +++ b/server/vce.c @@ -19,7 +19,6 @@ #include #include #include -// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vcd_main.h" #include "vcd_server.h" @@ -165,12 +164,6 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) return VCE_ERROR_OPERATION_FAILED; } - // if (0 != vcd_dbus_open_connection()) { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); - // ecore_shutdown(); - // return VCE_ERROR_OPERATION_FAILED; - // } - ret = vcd_initialize(callback); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize"); diff --git a/vc-server.conf b/vc-server.conf deleted file mode 100644 index 60a1d1b..0000000 --- a/vc-server.conf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - -- 2.7.4 From c339d4f5c648a60152d1bc82d8e5b3fefac2d428 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 29 Jun 2022 15:44:11 +0900 Subject: [PATCH 02/16] Change return values and Fix minor issues Change-Id: I1d10d83f58b3ec36ed3308b8906a5151b7571875 Signed-off-by: sooyeon --- client/vc.c | 50 +++++++-------- client/vc_client.c | 94 ++++++++++++++-------------- client/vc_data.cpp | 2 +- client/vc_mgr.c | 132 +++++++++++++++++++------------------- client/vc_mgr_client.c | 153 +++++++++++++++++++++++---------------------- client/vc_mgr_data.cpp | 2 +- client/vc_mgr_player.c | 16 ++--- client/vc_setting.c | 14 ++--- client/vc_tidl.c | 20 ++++-- client/vc_widget.c | 48 +++++++------- client/vc_widget_client.c | 78 +++++++++++------------ common/vc_cmd_db.c | 8 +-- common/vc_command.c | 50 +++++++-------- common/vc_config_mgr.c | 64 +++++++++---------- server/vcd_client_data.c | 146 +++++++++++++++++++++--------------------- server/vcd_config.c | 26 ++++---- server/vcd_engine_agent.c | 58 ++++++++--------- server/vcd_server.c | 46 +++++++------- server/vcd_server_data.cpp | 4 +- server/vce.c | 4 +- 20 files changed, 513 insertions(+), 502 deletions(-) diff --git a/client/vc.c b/client/vc.c index dd7be5a..4fed631 100644 --- a/client/vc.c +++ b/client/vc.c @@ -94,7 +94,7 @@ static int __vc_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } static int __check_privilege_initialize() @@ -1682,17 +1682,17 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid client"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } /* check state */ if (state != VC_STATE_READY) { SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] State is not READY"); if (VC_ERROR_SERVICE_RESET != reason) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] not connected client yet"); - return -1; + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] not connected client yet(%d)", reason); + return VC_ERROR_INVALID_STATE; } - return 0; + return VC_ERROR_NONE; } if (VC_ERROR_SERVICE_RESET == reason) { @@ -1711,7 +1711,7 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) vc_client_set_error(g_vc, reason); ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); - return 0; + return VC_ERROR_NONE; } int __vc_cb_error_to_app(int pid, int reason, const char* msg) @@ -1896,7 +1896,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) vc_client_set_result_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_result_cb(void) @@ -1922,7 +1922,7 @@ int vc_unset_result_cb(void) vc_client_set_result_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -1933,7 +1933,7 @@ int __vc_cb_service_state(int state) vc_client_get_service_state(g_vc, &before_state); if (current_state == before_state) { - return 0; + return VC_ERROR_NONE; } SLOG(LOG_DEBUG, TAG_VCC, "Service State changed : Before(%d) Current(%d)", @@ -1955,7 +1955,7 @@ int __vc_cb_service_state(int state) SLOG(LOG_WARN, TAG_VCC, "[WARNING] Service state changed callback is null"); } - return 0; + return VC_ERROR_NONE; } int __vc_cb_manager_pid(int manager_pid) @@ -1965,7 +1965,7 @@ int __vc_cb_manager_pid(int manager_pid) /* Save service state */ vc_client_set_mgr_pid(g_vc, manager_pid); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -1995,7 +1995,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* vc_client_set_service_state_changed_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_service_state_changed_cb(void) @@ -2021,7 +2021,7 @@ int vc_unset_service_state_changed_cb(void) vc_client_set_service_state_changed_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) @@ -2050,7 +2050,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) vc_client_set_state_changed_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_state_changed_cb(void) @@ -2076,7 +2076,7 @@ int vc_unset_state_changed_cb(void) vc_client_set_state_changed_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) @@ -2105,7 +2105,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, vc_client_set_current_lang_changed_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_current_language_changed_cb(void) @@ -2131,7 +2131,7 @@ int vc_unset_current_language_changed_cb(void) vc_client_set_current_lang_changed_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_error_cb(vc_error_cb callback, void* user_data) @@ -2160,7 +2160,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) vc_client_set_error_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_error_cb(void) @@ -2186,7 +2186,7 @@ int vc_unset_error_cb(void) vc_client_set_error_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_invocation_name(const char* name) @@ -3244,7 +3244,7 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) vc_client_set_tts_streaming_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_tts_unset_streaming_cb(void) @@ -3270,7 +3270,7 @@ int vc_tts_unset_streaming_cb(void) vc_client_set_tts_streaming_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_cb_utterance_status(int utt_id, int utt_status) @@ -3281,7 +3281,7 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) vc_client_get_tts_utterance_status_cb(g_vc, &callback, &user_data); if (NULL == callback) { SLOG(LOG_WARN, TAG_VCC, "[WARNING] Utterance status callback is null"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } SLOG(LOG_DEBUG, TAG_VCC, "Utterance status callback is called"); @@ -3289,7 +3289,7 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) callback(utt_id, (vc_tts_utterance_status_e)utt_status, user_data); vc_client_not_use_callback(g_vc); - return 0; + return VC_ERROR_NONE; } int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data) @@ -3318,7 +3318,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us vc_client_set_tts_utterance_status_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_tts_unset_utterance_status_cb(void) @@ -3344,6 +3344,6 @@ int vc_tts_unset_utterance_status_cb(void) vc_client_set_tts_utterance_status_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP diff --git a/client/vc_client.c b/client/vc_client.c index fe116b0..03e0908 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -170,14 +170,14 @@ int vc_client_create(vc_h* vc) *vc = temp; - return 0; + return VC_ERROR_NONE; } int vc_client_destroy(vc_h vc) { if (vc == NULL) { SLOG(LOG_ERROR, TAG_VCC, "Input parameter is NULL"); //LCOV_EXCL_LINE - return 0; + return VC_ERROR_NONE; } vc_client_s *data = NULL; @@ -203,14 +203,14 @@ int vc_client_destroy(vc_h vc) free(vc); data = NULL; vc = NULL; - return 0; + return VC_ERROR_NONE; } } } SLOG(LOG_ERROR, TAG_VCC, "[ERROR] client Not found"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } bool vc_client_is_valid(vc_h vc) @@ -264,12 +264,12 @@ int vc_client_get_handle(int pid, vc_h* vc) SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] pid(%d), handle(%d)", pid, data->vc->handle); if (pid == data->vc->handle) { *vc = data->vc; - return 0; + return VC_ERROR_NONE; } } } - return -1; + return VC_ERROR_INVALID_PARAMETER; } //LCOV_EXCL_STOP @@ -285,7 +285,7 @@ int vc_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) client->result_cb = callback; client->result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -300,7 +300,7 @@ int vc_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) *callback = client->result_cb; *user_data = client->result_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -315,7 +315,7 @@ int vc_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb client->service_state_changed_cb = callback; client->service_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -330,7 +330,7 @@ int vc_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* *callback = client->service_state_changed_cb; *user_data = client->service_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -345,7 +345,7 @@ int vc_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* client->state_changed_cb = callback; client->state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -360,7 +360,7 @@ int vc_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void* *callback = client->state_changed_cb; *user_data = client->state_changed_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -375,7 +375,7 @@ int vc_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_c client->current_lang_changed_cb = callback; client->current_lang_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -390,7 +390,7 @@ int vc_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_c *callback = client->current_lang_changed_cb; *user_data = client->current_lang_changed_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -405,7 +405,7 @@ int vc_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) client->error_cb = callback; client->error_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -420,7 +420,7 @@ int vc_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) *callback = client->error_cb; *user_data = client->error_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -435,7 +435,7 @@ int vc_client_set_service_state(vc_h vc, vc_service_state_e state) client->service_state = state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_service_state(vc_h vc, vc_service_state_e* state) @@ -448,7 +448,7 @@ int vc_client_get_service_state(vc_h vc, vc_service_state_e* state) *state = client->service_state; - return 0; + return VC_ERROR_NONE; } int vc_client_set_client_state(vc_h vc, vc_state_e state) @@ -462,7 +462,7 @@ int vc_client_set_client_state(vc_h vc, vc_state_e state) client->before_state = client->current_state; client->current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_client_state(vc_h vc, vc_state_e* state) @@ -475,7 +475,7 @@ int vc_client_get_client_state(vc_h vc, vc_state_e* state) *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) @@ -491,12 +491,12 @@ int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) if (NULL != data) { if (uid == data->vc->handle) { *state = data->current_state; - return 0; + return VC_ERROR_NONE; } } } - return -1; + return VC_ERROR_INVALID_PARAMETER; } int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) @@ -510,7 +510,7 @@ int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_st *before_state = client->before_state; *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_client_set_invocation_name(vc_h vc, const char* invocation_name) @@ -529,7 +529,7 @@ int vc_client_set_invocation_name(vc_h vc, const char* invocation_name) if (NULL != invocation_name) { client->invocation_name = strdup(invocation_name); } - return 0; + return VC_ERROR_NONE; } int vc_client_get_invocation_name(vc_h vc, char** invocation_name) @@ -542,7 +542,7 @@ int vc_client_get_invocation_name(vc_h vc, char** invocation_name) if (NULL != client->invocation_name) *invocation_name = strdup(client->invocation_name); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -556,7 +556,7 @@ int vc_client_set_xid(vc_h vc, int xid) client->xid = xid; - return 0; + return VC_ERROR_NONE; } int vc_client_get_xid(vc_h vc, int* xid) @@ -569,7 +569,7 @@ int vc_client_get_xid(vc_h vc, int* xid) *xid = client->xid; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -582,7 +582,7 @@ int vc_client_set_is_foreground(vc_h vc, bool value) return VC_ERROR_INVALID_PARAMETER; client->is_foreground = value; - return 0; + return VC_ERROR_NONE; } int vc_client_get_is_foreground(vc_h vc, bool* value) @@ -595,7 +595,7 @@ int vc_client_get_is_foreground(vc_h vc, bool* value) *value = client->is_foreground; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -610,7 +610,7 @@ int vc_client_set_exclusive_cmd(vc_h vc, bool value) client->exclusive_cmd = value; - return 0; + return VC_ERROR_NONE; } int vc_client_get_exclusive_cmd(vc_h vc, bool* value) @@ -623,7 +623,7 @@ int vc_client_get_exclusive_cmd(vc_h vc, bool* value) *value = client->exclusive_cmd; - return 0; + return VC_ERROR_NONE; } #endif //LCOV_EXCL_STOP @@ -638,7 +638,7 @@ int vc_client_set_error(vc_h vc, int reason) client->reason = reason; - return 0; + return VC_ERROR_NONE; } int vc_client_get_error(vc_h vc, int* reason) @@ -651,7 +651,7 @@ int vc_client_get_error(vc_h vc, int* reason) *reason = client->reason; - return 0; + return VC_ERROR_NONE; } @@ -670,7 +670,7 @@ int vc_client_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count++; - return 0; + return VC_ERROR_NONE; } int vc_client_not_use_callback(vc_h vc) @@ -682,7 +682,7 @@ int vc_client_not_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count--; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -698,7 +698,7 @@ int vc_client_set_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb callba client->auth_state_changed_cb = callback; client->auth_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_get_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb* callback, void** user_data) @@ -712,7 +712,7 @@ int vc_client_get_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb* callb *callback = client->auth_state_changed_cb; *user_data = client->auth_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_unset_auth_state_changed_cb(vc_h vc) @@ -726,7 +726,7 @@ int vc_client_unset_auth_state_changed_cb(vc_h vc) client->auth_state_changed_cb = NULL; client->auth_state_changed_user_data = NULL; - return 0; + return VC_ERROR_NONE; } int vc_client_set_auth_state(vc_h vc, vc_auth_state_e state) @@ -740,7 +740,7 @@ int vc_client_set_auth_state(vc_h vc, vc_auth_state_e state) client->auth_before_state = client->auth_current_state; client->auth_current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_auth_state(vc_h vc, vc_auth_state_e* state) @@ -753,7 +753,7 @@ int vc_client_get_auth_state(vc_h vc, vc_auth_state_e* state) *state = client->auth_current_state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_before_auth_state(vc_h vc, vc_auth_state_e* before, vc_auth_state_e* current) @@ -767,7 +767,7 @@ int vc_client_get_before_auth_state(vc_h vc, vc_auth_state_e* before, vc_auth_st *before = client->auth_before_state; *current = client->auth_current_state; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -781,7 +781,7 @@ int vc_client_set_mgr_pid(vc_h vc, int mgr_pid) client->mgr_pid = mgr_pid; - return 0; + return VC_ERROR_NONE; } int vc_client_get_mgr_pid(vc_h vc, int* mgr_pid) @@ -794,7 +794,7 @@ int vc_client_get_mgr_pid(vc_h vc, int* mgr_pid) *mgr_pid = client->mgr_pid; - return 0; + return VC_ERROR_NONE; } int vc_client_set_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb callback, void* user_data) @@ -808,7 +808,7 @@ int vc_client_set_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb callback, void* client->tts_streaming_cb = callback; client->tts_streaming_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_get_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb* callback, void** user_data) @@ -822,7 +822,7 @@ int vc_client_get_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb* callback, void* *callback = client->tts_streaming_cb; *user_data = client->tts_streaming_user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_set_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb callback, void* user_data) @@ -836,7 +836,7 @@ int vc_client_set_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb ca client->tts_utterance_status_cb = callback; client->tts_utterance_status_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_get_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb* callback, void** user_data) @@ -850,5 +850,5 @@ int vc_client_get_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb* c *callback = client->tts_utterance_status_cb; *user_data = client->tts_utterance_status_user_data; - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_data.cpp b/client/vc_data.cpp index afc475d..d66cab3 100644 --- a/client/vc_data.cpp +++ b/client/vc_data.cpp @@ -127,7 +127,7 @@ int vc_data_clear_tts_data_by_uttid(int utt_id) if (g_tts_data.empty()) { SLOG(LOG_ERROR, TAG_VCC, "[DATA ERROR] There is no tts data"); pthread_mutex_unlock(&g_tts_data_mutex); - return -1; + return VC_ERROR_EMPTY; } std::list::iterator iter; diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 1203bf6..5019344 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -151,7 +151,7 @@ static int __vc_mgr_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } static int __check_privilege_initialize() @@ -831,7 +831,7 @@ int vc_mgr_set_demandable_client_rule(const char* rule) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_demandable_client_rule(void) @@ -855,7 +855,7 @@ int vc_mgr_unset_demandable_client_rule(void) } // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_is_command_format_supported(int format, bool* support) @@ -1139,7 +1139,7 @@ int vc_mgr_unset_command_list(void) SLOG(LOG_ERROR, TAG_VCM, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_command_list_from_file(const char* file_path, int type) @@ -1381,7 +1381,7 @@ int vc_mgr_get_audio_type(char** audio_id) } // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) @@ -1474,7 +1474,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) if (0 != vc_info_parser_get_client_info(&client_info_list)) { SLOG(LOG_INFO, TAG_VCM, "[DEBUG] No client"); - return 0; + return VC_ERROR_NONE; } if (VC_NO_FOREGROUND_PID != fg_pid) { @@ -1533,7 +1533,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } } else { SLOG(LOG_INFO, TAG_VCM, "[Manager] No foreground app"); @@ -1568,7 +1568,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_ERROR, TAG_VCM, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) @@ -1614,7 +1614,7 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) } vc_mgr_client_set_recognition_mode(g_vc_m, mode); - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) @@ -1649,7 +1649,7 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) } SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Get recognition mode = %d", *mode); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_private_data(const char* key, const char* data) @@ -1704,7 +1704,7 @@ int vc_mgr_set_private_data(const char* key, const char* data) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_private_data(const char* key, char** data) @@ -1769,7 +1769,7 @@ int vc_mgr_get_private_data(const char* key, char** data) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_domain(const char* domain) @@ -1824,7 +1824,7 @@ int vc_mgr_set_domain(const char* domain) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) @@ -1883,7 +1883,7 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) } SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request) @@ -1943,7 +1943,7 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e } SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_start(bool exclusive_command_option) @@ -2189,7 +2189,7 @@ int __vc_mgr_cb_set_volume(float volume) g_cnt = 1; g_m_set_volume_timer = ecore_timer_add(0.05, __vc_mgr_set_volume_timer_cb, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_mgr_set_volume(float volume) @@ -2197,7 +2197,7 @@ int __vc_mgr_set_volume(float volume) // called by app directly g_volume_db = volume; - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_recording_volume(float* volume) @@ -2230,7 +2230,7 @@ int vc_mgr_get_recording_volume(float* volume) *volume = g_volume_db; - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_set_foreground(int pid, bool value) @@ -2265,7 +2265,7 @@ int __vc_mgr_cb_set_foreground(int pid, bool value) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) @@ -2324,7 +2324,7 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_mgr_set_select_result(void *data) @@ -2577,7 +2577,7 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set all result callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_all_result_cb(void) @@ -2605,7 +2605,7 @@ int vc_mgr_unset_all_result_cb(void) vc_mgr_client_set_all_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) @@ -2636,7 +2636,7 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) vc_mgr_client_set_result_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_result_cb(void) @@ -2664,7 +2664,7 @@ int vc_mgr_unset_result_cb(void) vc_mgr_client_set_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) @@ -2695,7 +2695,7 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) vc_mgr_client_set_pre_result_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_pre_result_cb(void) @@ -2723,7 +2723,7 @@ int vc_mgr_unset_pre_result_cb(void) vc_mgr_client_set_pre_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_error_message(char** err_msg) @@ -2795,13 +2795,13 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[WARNING] Invalid client"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } /* check state */ if (state != VC_STATE_INITIALIZED && state != VC_STATE_READY) { SLOG(LOG_ERROR, TAG_VCM, "[WARNING] not connected client yet"); - return -1; + return VC_ERROR_INVALID_STATE; } vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); @@ -2813,7 +2813,7 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) vc_mgr_client_get_service_state(g_vc_m, &service_state); if (VC_SERVICE_STATE_UPDATING == service_state) { SLOG(LOG_INFO, TAG_VCM, "[INFO] VC daemon is terminated by update manager"); - return 0; + return VC_ERROR_NONE; } vc_mgr_client_set_client_state(g_vc_m, VC_STATE_INITIALIZED); @@ -2830,7 +2830,7 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) vc_mgr_client_set_error_message(g_vc_m, msg); __vc_mgr_notify_error(g_vc_m); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_mgr_notify_state_changed(void *data) @@ -2886,7 +2886,7 @@ int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) vc_mgr_client_set_state_changed_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set state changed callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_state_changed_cb(void) @@ -2914,7 +2914,7 @@ int vc_mgr_unset_state_changed_cb(void) vc_mgr_client_set_state_changed_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_service_state(int state) @@ -2942,7 +2942,7 @@ int __vc_mgr_cb_service_state(int state) if (current_state == before_state) { SLOG(LOG_WARN, TAG_VCM, "Service State NOT changed : Before(%d) Current(%d)", before_state, current_state); - return 0; + return VC_ERROR_NONE; } /* Save service state */ @@ -2961,7 +2961,7 @@ int __vc_mgr_cb_service_state(int state) SLOG(LOG_WARN, TAG_VCM, "[WARNING] Service state changed callback is null"); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) @@ -2993,7 +2993,7 @@ int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, vo vc_mgr_client_set_service_state_changed_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set service state changed callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_service_state_changed_cb(void) @@ -3020,7 +3020,7 @@ int vc_mgr_unset_service_state_changed_cb(void) } vc_mgr_client_set_service_state_changed_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void* user_data) @@ -3052,7 +3052,7 @@ int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void vc_mgr_client_set_speech_detected_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set speech detected callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_speech_detected_cb(void) @@ -3079,7 +3079,7 @@ int vc_mgr_unset_speech_detected_cb(void) } vc_mgr_client_set_speech_detected_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) @@ -3111,7 +3111,7 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba vc_mgr_client_set_current_lang_changed_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set current language changed callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_current_language_changed_cb(void) @@ -3139,7 +3139,7 @@ int vc_mgr_unset_current_language_changed_cb(void) vc_mgr_client_set_current_lang_changed_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) @@ -3170,7 +3170,7 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) vc_mgr_client_set_error_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_error_cb(void) @@ -3198,7 +3198,7 @@ int vc_mgr_unset_error_cb(void) vc_mgr_client_set_error_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous) @@ -3217,7 +3217,7 @@ int __vc_mgr_cb_dialog(int pid, const char* disp_text, const char* utt_text, boo SLOG(LOG_WARN, TAG_VCM, "[WARNING] Error callback is null"); } - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_private_data_set(const char* key, const char* data) @@ -3367,7 +3367,7 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d vc_mgr_client_set_dialog_request_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_dialog_request_cb(void) @@ -3395,7 +3395,7 @@ int vc_mgr_unset_dialog_request_cb(void) vc_mgr_client_set_dialog_request_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* user_data) @@ -3426,7 +3426,7 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us vc_mgr_client_set_private_data_set_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_private_data_set_cb(void) @@ -3454,7 +3454,7 @@ int vc_mgr_unset_private_data_set_cb(void) vc_mgr_client_set_private_data_set_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callback, void* user_data) @@ -3485,7 +3485,7 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba vc_mgr_client_set_private_data_requested_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_private_data_requested_cb(void) @@ -3513,7 +3513,7 @@ int vc_mgr_unset_private_data_requested_cb(void) vc_mgr_client_set_private_data_requested_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } static bool __vc_mgr_check_demandable_client(int pid) @@ -3583,7 +3583,7 @@ int __vc_mgr_request_auth_enable(int pid) vc_mgr_client_set_valid_authorized_client(g_vc_m, pid); } - return 0; + return VC_ERROR_NONE; } int __vc_mgr_request_auth_disable(int pid) @@ -3609,7 +3609,7 @@ int __vc_mgr_request_auth_disable(int pid) } } - return 0; + return VC_ERROR_NONE; } static Eina_Bool __request_auth_start(void* data) @@ -3644,7 +3644,7 @@ int __vc_mgr_request_auth_start(int pid) /* add timer for start recording */ ecore_timer_add(0, __request_auth_start, NULL); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __request_auth_stop(void* data) @@ -3670,7 +3670,7 @@ int __vc_mgr_request_auth_stop(int pid) /* add timer for start recording */ ecore_timer_add(0, __request_auth_stop, NULL); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __request_auth_cancel(void* data) @@ -3696,7 +3696,7 @@ int __vc_mgr_request_auth_cancel(int pid) /* add timer for start recording */ ecore_timer_add(0, __request_auth_cancel, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callback, void* user_data) @@ -3726,7 +3726,7 @@ int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callba vc_mgr_client_set_specific_engine_result_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_specific_engine_result_cb(void) { @@ -3748,7 +3748,7 @@ int vc_mgr_unset_specific_engine_result_cb(void) vc_mgr_client_set_specific_engine_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } void __vc_mgr_cb_specific_engine_result(const char* engine_app_id, const char* event, const char* result) @@ -3802,7 +3802,7 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set feedback audio format callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_feedback_audio_format_cb() @@ -3833,7 +3833,7 @@ int vc_mgr_unset_feedback_audio_format_cb() SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Unset feedback audio format callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void* user_data) @@ -3873,7 +3873,7 @@ int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_feedback_streaming_cb() @@ -3910,7 +3910,7 @@ int vc_mgr_unset_feedback_streaming_cb() SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Unset feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* user_data) @@ -3951,7 +3951,7 @@ int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* us SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_vc_tts_streaming_cb() @@ -3989,7 +3989,7 @@ int vc_mgr_unset_vc_tts_streaming_cb() SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Unset feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } static void __tts_feedback_thread(void* data, Ecore_Thread* thread) @@ -4143,7 +4143,7 @@ int vc_mgr_start_feedback(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player play, ret(%d)", ret); } #endif - return 0; + return VC_ERROR_NONE; } int vc_mgr_stop_feedback(void) @@ -4183,7 +4183,7 @@ int vc_mgr_stop_feedback(void) if (0 != ret || NULL == feedback_data) { /* empty queue */ SLOG(LOG_INFO, TAG_VCM, "[INFO] No feedback data to stop any more"); - return 0; + return VC_ERROR_NONE; } ret = vc_mgr_data_clear_feedback_data(&feedback_data); if (0 != ret) { @@ -4489,7 +4489,7 @@ int __vc_change_system_volume(vc_system_volume_event_e volume_event) } SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Change system volume"); - return 0; + return VC_ERROR_NONE; } int __vc_recover_system_volume() @@ -4521,7 +4521,7 @@ int __vc_recover_system_volume() } SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Recover system volume"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_change_system_volume(vc_system_volume_event_e event) diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index f463c48..9da3025 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -241,14 +241,14 @@ int vc_mgr_client_create(vc_h* vc) *vc = temp; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_destroy(vc_h vc) { if (vc == NULL) { SLOG(LOG_ERROR, TAG_VCM, "Input parameter is NULL"); - return 0; + return VC_ERROR_NONE; } vc_mgr_client_s *data = NULL; @@ -285,14 +285,14 @@ int vc_mgr_client_destroy(vc_h vc) data = NULL; vc = NULL; - return 0; + return VC_ERROR_NONE; } } } SLOG(LOG_ERROR, TAG_VCM, "[ERROR] client Not found"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } bool vc_mgr_client_is_valid(vc_h vc) @@ -342,12 +342,13 @@ int vc_mgr_client_get_handle(unsigned int uid, vc_h* vc) if (NULL != data) { if (uid == data->vc->handle) { *vc = data->vc; - return 0; + return VC_ERROR_NONE; } } } - return -1; + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to find the corresponding handle."); + return VC_ERROR_INVALID_PARAMETER; } int vc_mgr_client_get_pid(vc_h vc, int* pid) @@ -357,11 +358,11 @@ int vc_mgr_client_get_pid(vc_h vc, int* pid) /* check handle */ if (NULL == client) { SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] vc is not valid"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } *pid = client->pid; - return 0; + return VC_ERROR_NONE; } /* set/get callback function */ @@ -376,7 +377,7 @@ int vc_mgr_client_set_all_result_cb(vc_h vc, vc_mgr_all_result_cb callback, void client->all_result_cb = callback; client->all_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_all_result_cb(vc_h vc, vc_mgr_all_result_cb* callback, void** user_data) @@ -390,7 +391,7 @@ int vc_mgr_client_get_all_result_cb(vc_h vc, vc_mgr_all_result_cb* callback, voi *callback = client->all_result_cb; *user_data = client->all_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) @@ -404,7 +405,7 @@ int vc_mgr_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) client->result_cb = callback; client->result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) @@ -418,7 +419,7 @@ int vc_mgr_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_dat *callback = client->result_cb; *user_data = client->result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb callback, void* user_data) @@ -432,7 +433,7 @@ int vc_mgr_client_set_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb callback, void client->pre_result_cb = callback; client->pre_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb* callback, void** user_data) @@ -446,7 +447,7 @@ int vc_mgr_client_get_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb* callback, voi *callback = client->pre_result_cb; *user_data = client->pre_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data) @@ -460,7 +461,7 @@ int vc_mgr_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed client->service_state_changed_cb = callback; client->service_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data) @@ -474,7 +475,7 @@ int vc_mgr_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed *callback = client->service_state_changed_cb; *user_data = client->service_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data) @@ -488,7 +489,7 @@ int vc_mgr_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, vo client->state_changed_cb = callback; client->state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void** user_data) @@ -502,7 +503,7 @@ int vc_mgr_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, v *callback = client->state_changed_cb; *user_data = client->state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_cb callback, void* user_data) @@ -516,7 +517,7 @@ int vc_mgr_client_set_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_c client->speech_detected_cb = callback; client->speech_detected_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_cb* callback, void** user_data) @@ -530,7 +531,7 @@ int vc_mgr_client_get_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_c *callback = client->speech_detected_cb; *user_data = client->speech_detected_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data) @@ -544,7 +545,7 @@ int vc_mgr_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_chang client->current_lang_changed_cb = callback; client->current_lang_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb* callback, void** user_data) @@ -558,7 +559,7 @@ int vc_mgr_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_chang *callback = client->current_lang_changed_cb; *user_data = client->current_lang_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) @@ -572,7 +573,7 @@ int vc_mgr_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) client->error_cb = callback; client->error_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) @@ -586,7 +587,7 @@ int vc_mgr_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) *callback = client->error_cb; *user_data = client->error_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb callback, void* user_data) @@ -600,7 +601,7 @@ int vc_mgr_client_set_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb callba client->diaglog_requst_cb = callback; client->dialog_request_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb* callback, void** user_data) @@ -614,7 +615,7 @@ int vc_mgr_client_get_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb* callb *callback = client->diaglog_requst_cb; *user_data = client->dialog_request_user_data; - return 0; + return VC_ERROR_NONE; } @@ -629,7 +630,7 @@ int vc_mgr_client_set_private_data_set_cb(vc_h vc, vc_mgr_private_data_set_cb ca client->private_data_set_cb = callback; client->private_data_set_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_private_data_set_cb(vc_h vc, vc_mgr_private_data_set_cb* callback, void** user_data) @@ -643,7 +644,7 @@ int vc_mgr_client_get_private_data_set_cb(vc_h vc, vc_mgr_private_data_set_cb* c *callback = client->private_data_set_cb; *user_data = client->private_data_set_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_private_data_requested_cb(vc_h vc, vc_mgr_private_data_requested_cb callback, void* user_data) @@ -657,7 +658,7 @@ int vc_mgr_client_set_private_data_requested_cb(vc_h vc, vc_mgr_private_data_req client->private_data_requested_cb = callback; client->private_data_requested_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_private_data_requested_cb(vc_h vc, vc_mgr_private_data_requested_cb* callback, void** user_data) @@ -671,7 +672,7 @@ int vc_mgr_client_get_private_data_requested_cb(vc_h vc, vc_mgr_private_data_req *callback = client->private_data_requested_cb; *user_data = client->private_data_requested_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb callback, void* user_data) @@ -685,7 +686,7 @@ int vc_mgr_client_set_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_fo client->feedback_audio_format_cb = callback; client->feedback_audio_format_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb* callback, void** user_data) @@ -699,7 +700,7 @@ int vc_mgr_client_get_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_fo *callback = client->feedback_audio_format_cb; *user_data = client->feedback_audio_format_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb callback, void* user_data) @@ -713,7 +714,7 @@ int vc_mgr_client_set_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_c client->feedback_streaming_cb = callback; client->feedback_streaming_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb* callback, void** user_data) @@ -727,7 +728,7 @@ int vc_mgr_client_get_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_c *callback = client->feedback_streaming_cb; *user_data = client->feedback_streaming_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb callback, void* user_data) @@ -741,7 +742,7 @@ int vc_mgr_client_set_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb ca client->vc_tts_streaming_cb = callback; client->vc_tts_streaming_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb* callback, void** user_data) @@ -755,7 +756,7 @@ int vc_mgr_client_get_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb* c *callback = client->vc_tts_streaming_cb; *user_data = client->vc_tts_streaming_user_data; - return 0; + return VC_ERROR_NONE; } /* set/get option */ @@ -769,7 +770,7 @@ int vc_mgr_client_set_service_state(vc_h vc, vc_service_state_e state) client->service_state = state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_service_state(vc_h vc, vc_service_state_e* state) @@ -782,7 +783,7 @@ int vc_mgr_client_get_service_state(vc_h vc, vc_service_state_e* state) *state = client->service_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_internal_state(vc_h vc, vc_internal_state_e state) @@ -795,7 +796,7 @@ int vc_mgr_client_set_internal_state(vc_h vc, vc_internal_state_e state) client->internal_state = state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_internal_state(vc_h vc, vc_internal_state_e* state) @@ -808,7 +809,7 @@ int vc_mgr_client_get_internal_state(vc_h vc, vc_internal_state_e* state) *state = client->internal_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state) @@ -822,7 +823,7 @@ int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state) client->before_state = client->current_state; client->current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state) @@ -835,7 +836,7 @@ int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state) *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) @@ -851,12 +852,12 @@ int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) if (NULL != data) { if (uid == data->vc->handle) { *state = data->current_state; - return 0; + return VC_ERROR_NONE; } } } - return -1; + return VC_ERROR_INVALID_PARAMETER; } int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) @@ -870,7 +871,7 @@ int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* befor *before_state = client->before_state; *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_error(vc_h vc, int reason) @@ -883,7 +884,7 @@ int vc_mgr_client_set_error(vc_h vc, int reason) client->reason = reason; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_error(vc_h vc, int* reason) @@ -896,7 +897,7 @@ int vc_mgr_client_get_error(vc_h vc, int* reason) *reason = client->reason; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_error_message(vc_h vc, const char* err_msg) @@ -919,7 +920,7 @@ int vc_mgr_client_set_error_message(vc_h vc, const char* err_msg) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_error_message(vc_h vc, char** err_msg) @@ -937,7 +938,7 @@ int vc_mgr_client_get_error_message(vc_h vc, char** err_msg) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_enable_command_type(vc_h vc, vc_cmd_type_e cmd_type) @@ -952,7 +953,7 @@ int vc_mgr_client_enable_command_type(vc_h vc, vc_cmd_type_e cmd_type) client->disabled_cmd_type &= ~(1 << cmd_type); - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_disable_command_type(vc_h vc, vc_cmd_type_e cmd_type) @@ -967,7 +968,7 @@ int vc_mgr_client_disable_command_type(vc_h vc, vc_cmd_type_e cmd_type) client->disabled_cmd_type |= (1 << cmd_type); - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_disabled_command_type(vc_h vc, int* disabled_cmd_type) @@ -982,7 +983,7 @@ int vc_mgr_client_get_disabled_command_type(vc_h vc, int* disabled_cmd_type) *disabled_cmd_type = client->disabled_cmd_type; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_exclusive_command(vc_h vc, bool value) @@ -995,7 +996,7 @@ int vc_mgr_client_set_exclusive_command(vc_h vc, bool value) client->exclusive_cmd_option = value; - return 0; + return VC_ERROR_NONE; } bool vc_mgr_client_get_exclusive_command(vc_h vc) @@ -1027,7 +1028,7 @@ int vc_mgr_client_set_all_result(vc_h vc, int event, const char* result_text) client->all_result_text = strdup(result_text); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_all_result(vc_h vc, int* event, char** result_text) @@ -1045,7 +1046,7 @@ int vc_mgr_client_get_all_result(vc_h vc, int* event, char** result_text) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_unset_all_result(vc_h vc) @@ -1063,7 +1064,7 @@ int vc_mgr_client_unset_all_result(vc_h vc) client->all_result_text = NULL; } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_audio_type(vc_h vc, const char* audio_id) @@ -1082,13 +1083,13 @@ int vc_mgr_client_set_audio_type(vc_h vc, const char* audio_id) client->audio_id = strdup(audio_id); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_audio_type(vc_h vc, char** audio_id) { if (NULL == audio_id) { - return -1; + return VC_ERROR_INVALID_PARAMETER; } vc_mgr_client_s* client = __mgr_client_get(vc); @@ -1102,7 +1103,7 @@ int vc_mgr_client_get_audio_type(vc_h vc, char** audio_id) else *audio_id = NULL; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_recognition_mode(vc_h vc, vc_recognition_mode_e mode) @@ -1115,13 +1116,13 @@ int vc_mgr_client_set_recognition_mode(vc_h vc, vc_recognition_mode_e mode) client->recognition_mode = mode; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_recognition_mode(vc_h vc, vc_recognition_mode_e* mode) { if (NULL == mode) { - return -1; + return VC_ERROR_INVALID_PARAMETER; } vc_mgr_client_s* client = __mgr_client_get(vc); @@ -1131,7 +1132,7 @@ int vc_mgr_client_get_recognition_mode(vc_h vc, vc_recognition_mode_e* mode) return VC_ERROR_INVALID_PARAMETER; *mode = client->recognition_mode; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_foreground(vc_h vc, int pid, bool value) @@ -1150,7 +1151,7 @@ int vc_mgr_client_set_foreground(vc_h vc, int pid, bool value) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_foreground(vc_h vc, int* pid) @@ -1162,7 +1163,7 @@ int vc_mgr_client_get_foreground(vc_h vc, int* pid) return VC_ERROR_INVALID_PARAMETER; *pid = client->foreground_pid; - return 0; + return VC_ERROR_NONE; } /* utils */ @@ -1180,7 +1181,7 @@ int vc_mgr_client_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count++; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_not_use_callback(vc_h vc) @@ -1192,7 +1193,7 @@ int vc_mgr_client_not_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count--; - return 0; + return VC_ERROR_NONE; } /* Authority */ @@ -1218,7 +1219,7 @@ int vc_mgr_client_add_authorized_client(vc_h vc, int pid) SLOG(LOG_DEBUG, TAG_VCM, "Add authorized client - %d", pid); - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_remove_authorized_client(vc_h vc, int pid) @@ -1245,7 +1246,7 @@ int vc_mgr_client_remove_authorized_client(vc_h vc, int pid) data = NULL; SLOG(LOG_DEBUG, TAG_VCM, "Remove authorized client - %d", pid); - return 0; + return VC_ERROR_NONE; } } } @@ -1294,7 +1295,7 @@ int vc_mgr_client_set_valid_authorized_client(vc_h vc, int pid) client->valid_authorized_pid = pid; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_valid_authorized_client(vc_h vc, int* pid) @@ -1307,7 +1308,7 @@ int vc_mgr_client_get_valid_authorized_client(vc_h vc, int* pid) *pid = client->valid_authorized_pid; - return 0; + return VC_ERROR_NONE; } bool vc_mgr_client_is_valid_authorized_client(vc_h vc, int pid) @@ -1334,7 +1335,7 @@ int vc_mgr_client_set_start_by_client(vc_h vc, bool option) client->start_by_client = option; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_start_by_client(vc_h vc, bool* option) @@ -1347,7 +1348,7 @@ int vc_mgr_client_get_start_by_client(vc_h vc, bool* option) *option = client->start_by_client; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb callback, void* user_data) @@ -1361,7 +1362,7 @@ int vc_mgr_client_set_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_ client->specific_engine_result_cb = callback; client->specific_engine_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb* callback, void** user_data) @@ -1375,7 +1376,7 @@ int vc_mgr_client_get_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_ *callback = client->specific_engine_result_cb; *user_data = client->specific_engine_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e streaming_mode) @@ -1388,7 +1389,7 @@ int vc_mgr_client_set_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e st client->streaming_mode = streaming_mode; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e* streaming_mode) @@ -1401,5 +1402,5 @@ int vc_mgr_client_get_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e* s *streaming_mode = client->streaming_mode; - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_mgr_data.cpp b/client/vc_mgr_data.cpp index 8301fcd..27c96a2 100644 --- a/client/vc_mgr_data.cpp +++ b/client/vc_mgr_data.cpp @@ -66,7 +66,7 @@ int vc_mgr_data_get_feedback_data(vc_feedback_data_s** data) *data = NULL; pthread_mutex_unlock(&g_feedback_data_mutex); - return -1; + return VC_ERROR_EMPTY; } std::list::iterator iter; diff --git a/client/vc_mgr_player.c b/client/vc_mgr_player.c index 06915f9..5bfd5be 100644 --- a/client/vc_mgr_player.c +++ b/client/vc_mgr_player.c @@ -78,7 +78,7 @@ static int __create_audio_out(int rate, vc_audio_channel_e channel, vc_audio_typ if (AUDIO_IO_ERROR_NONE != ret) { g_audio_state = AUDIO_STATE_NONE; g_audio_h = NULL; - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio"); + SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio. ret(%d)", ret); return -1; } else { SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Create audio"); @@ -103,7 +103,7 @@ static int __destroy_audio_out() int ret = -1; ret = audio_out_destroy(g_audio_h); if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to destroy audio"); + SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to destroy audio. ret(%d)", ret); return -1; } else { SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Destroy audio"); @@ -131,12 +131,12 @@ int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e aud ret = __create_audio_out(rate, channel, audio_type); if (0 != ret) { - return -1; + return VC_ERROR_OPERATION_FAILED; } g_player_init = true; - return 0; + return VC_ERROR_NONE; } int vc_mgr_player_release() @@ -167,12 +167,12 @@ int vc_mgr_player_release() ret = __destroy_audio_out(); if (0 != ret) { - return -1; + return VC_ERROR_OPERATION_FAILED; } g_player_init = false; - return 0; + return VC_ERROR_NONE; } static void __play_feedback_thread(void* data, Ecore_Thread* thread) @@ -377,7 +377,7 @@ int vc_mgr_player_play() ecore_thread_run(__play_feedback_thread, __end_play_feedback_thread, NULL, NULL); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_player_stop() @@ -409,5 +409,5 @@ int vc_mgr_player_stop() thread_count = ecore_thread_active_get(); } - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_setting.c b/client/vc_setting.c index 1e99383..5f26cbe 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -396,7 +396,7 @@ int vc_setting_get_auto_language(bool* value) SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_set_enabled(bool value) @@ -477,7 +477,7 @@ int vc_setting_set_enabled_changed_cb(vc_setting_enabled_changed_cb callback, vo SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_unset_enabled_changed_cb() @@ -495,7 +495,7 @@ int vc_setting_unset_enabled_changed_cb() SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_set_current_language_changed_cb(vc_setting_current_language_changed_cb callback, void* user_data) @@ -519,7 +519,7 @@ int vc_setting_set_current_language_changed_cb(vc_setting_current_language_chang SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_unset_current_language_changed_cb() @@ -537,7 +537,7 @@ int vc_setting_unset_current_language_changed_cb() SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_set_engine_changed_cb(vc_setting_engine_changed_cb callback, void *user_data) @@ -553,7 +553,7 @@ int vc_setting_set_engine_changed_cb(vc_setting_engine_changed_cb callback, void g_engine_changed_user_data = user_data; SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_unset_engine_changed_cb() @@ -570,5 +570,5 @@ int vc_setting_unset_engine_changed_cb() g_engine_changed_user_data = NULL; SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 6a6caef..dbfed0d 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -200,8 +200,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) } /* VCD_METHOD_SEND_MANAGER_PID */ else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) { /* signal!!! */ - char* reason; - char* daemon_pid; + char* reason = NULL; + char* daemon_pid = NULL; char* err_msg = NULL; bundle_get_str(msg, VC_BUNDLE_REASON, &reason); @@ -226,8 +226,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) } /* VCD_METHOD_ERROR_TO_APP */ else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) { /* signal!!! */ - char* pid; - char* utt_id; + char* pid = NULL; + char* utt_id = NULL; char* utt_status = NULL; bundle_get_str(msg, VC_BUNDLE_PID, &pid); @@ -262,6 +262,11 @@ void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_vc_pro static int __create_notify_callback_handle(vc_tidl_info_s* info) { + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter"); + return VC_ERROR_INVALID_PARAMETER; + } + if (NULL != info->notify_cb_h) { rpc_port_proxy_vc_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h); info->notify_cb_h = NULL; @@ -281,7 +286,12 @@ static int __create_notify_callback_handle(vc_tidl_info_s* info) static int __create_feedback_callback_handle(vc_tidl_info_s* info) { - if (NULL != info) { + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter"); + return VC_ERROR_INVALID_PARAMETER; + } + + if (NULL != info->feedback_cb_h) { rpc_port_proxy_vc_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h); info->feedback_cb_h = NULL; } diff --git a/client/vc_widget.c b/client/vc_widget.c index f0e3b01..5161784 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -86,7 +86,7 @@ static int __vc_widget_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } const char* vc_tag() @@ -270,7 +270,7 @@ static int _vc_widget_wait_to_end_thread(void) count++; } SLOG(LOG_WARN, TAG_VCW, "[Widget] prepare_thread is terminated"); - return 0; + return VC_ERROR_NONE; } int vc_widget_deinitialize(vc_h vc_w) @@ -1101,7 +1101,7 @@ int vc_widget_stop() } } while (0 != ret); - return 0; + return VC_ERROR_NONE; } #endif @@ -1147,7 +1147,7 @@ int vc_widget_cancel(vc_h vc_w) SLOG(LOG_DEBUG, TAG_VCW, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } static void __vc_widget_notify_error(void *data) @@ -1194,13 +1194,13 @@ int __vc_widget_cb_error(int reason, int daemon_pid, char* msg) if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[WARNING] Invalid client"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } /* check state */ if (state != VC_STATE_READY) { SLOG(LOG_ERROR, TAG_VCW, "[WARNING] not connected client yet"); - return -1; + return VC_ERROR_INVALID_STATE; } if (VC_ERROR_SERVICE_RESET == reason) { @@ -1221,7 +1221,7 @@ int __vc_widget_cb_error(int reason, int daemon_pid, char* msg) } } - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_widget_start_recording(void *data) @@ -1504,7 +1504,7 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) vc_widget_client_set_result_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_result_cb(vc_h vc_w) @@ -1534,7 +1534,7 @@ int vc_widget_unset_result_cb(vc_h vc_w) vc_widget_client_set_result_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, void* user_data) @@ -1567,7 +1567,7 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, vc_widget_client_set_show_tooltip_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_show_tooltip_cb(vc_h vc_w) @@ -1597,7 +1597,7 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) vc_widget_client_set_show_tooltip_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current_command_list_cb callback, void* user_data) @@ -1627,7 +1627,7 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current vc_widget_client_set_send_command_list_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) @@ -1657,7 +1657,7 @@ int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) vc_widget_client_set_send_command_list_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_widget_cb_service_state(int state) @@ -1703,7 +1703,7 @@ int __vc_widget_cb_service_state(int state) } } - return 0; + return VC_ERROR_NONE; } int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_cb callback, void* user_data) @@ -1733,7 +1733,7 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c vc_widget_client_set_service_state_changed_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_service_state_changed_cb(vc_h vc_w) @@ -1763,7 +1763,7 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) vc_widget_client_set_service_state_changed_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void* user_data) @@ -1796,7 +1796,7 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void vc_widget_client_set_state_changed_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_state_changed_cb(vc_h vc_w) @@ -1826,7 +1826,7 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) vc_widget_client_set_state_changed_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user_data) @@ -1859,7 +1859,7 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user vc_widget_client_set_asr_result_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_asr_result_cb(vc_h vc_w) @@ -1889,7 +1889,7 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) vc_widget_client_set_asr_result_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_changed_cb callback, void* user_data) @@ -1922,7 +1922,7 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha vc_widget_client_set_current_lang_changed_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_current_language_changed_cb(vc_h vc_w) @@ -1952,7 +1952,7 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) vc_widget_client_set_current_lang_changed_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) @@ -1985,7 +1985,7 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) vc_widget_client_set_error_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_error_cb(vc_h vc_w) @@ -2015,6 +2015,6 @@ int vc_widget_unset_error_cb(vc_h vc_w) vc_widget_client_set_error_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_widget_client.c b/client/vc_widget_client.c index c18036e..891ba75 100644 --- a/client/vc_widget_client.c +++ b/client/vc_widget_client.c @@ -125,14 +125,14 @@ int vc_widget_client_create(vc_h* vc) *vc = temp; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_destroy(vc_h vc) { if (vc == NULL) { SLOG(LOG_ERROR, TAG_VCW, "Input parameter is NULL"); - return 0; + return VC_ERROR_NONE; } vc_widget_s *data = NULL; @@ -158,7 +158,7 @@ int vc_widget_client_destroy(vc_h vc) vc = NULL; pthread_mutex_unlock(&g_widget_list_mutex); - return 0; + return VC_ERROR_NONE; } } } @@ -166,7 +166,7 @@ int vc_widget_client_destroy(vc_h vc) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] widget Not found"); pthread_mutex_unlock(&g_widget_list_mutex); - return -1; + return VC_ERROR_INVALID_PARAMETER; } GSList* vc_widget_client_get_client_list() @@ -230,13 +230,13 @@ int vc_widget_client_get_handle(unsigned int uid, vc_h* vc) if (uid == data->vc->handle) { *vc = data->vc; pthread_mutex_unlock(&g_widget_list_mutex); - return 0; + return VC_ERROR_NONE; } } } pthread_mutex_unlock(&g_widget_list_mutex); - return -1; + return VC_ERROR_INVALID_PARAMETER; } /* set/get callback function */ @@ -251,7 +251,7 @@ int vc_widget_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_da widget->result_cb = callback; widget->result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) @@ -265,7 +265,7 @@ int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_ *callback = widget->result_cb; *user_data = widget->result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_asr_result_enabled(vc_h vc, bool enabled) @@ -278,7 +278,7 @@ int vc_widget_client_set_asr_result_enabled(vc_h vc, bool enabled) widget->asr_result_enabled = enabled; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_asr_result_enabled(vc_h vc, bool* enabled) @@ -291,7 +291,7 @@ int vc_widget_client_get_asr_result_enabled(vc_h vc, bool* enabled) *enabled = widget->asr_result_enabled; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* user_data) @@ -305,7 +305,7 @@ int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* widget->asr_result_cb = callback; widget->asr_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void** user_data) @@ -319,7 +319,7 @@ int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void *callback = widget->asr_result_cb; *user_data = widget->asr_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data) @@ -333,7 +333,7 @@ int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_chan widget->service_state_changed_cb = callback; widget->service_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data) @@ -347,7 +347,7 @@ int vc_widget_client_get_service_state_changed_cb(vc_h vc, vc_service_state_chan *callback = widget->service_state_changed_cb; *user_data = widget->service_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data) @@ -361,7 +361,7 @@ int vc_widget_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, widget->state_changed_cb = callback; widget->state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void** user_data) @@ -375,7 +375,7 @@ int vc_widget_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback *callback = widget->state_changed_cb; *user_data = widget->state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb callback, void* user_data) @@ -389,7 +389,7 @@ int vc_widget_client_set_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb call widget->show_tooltip_cb = callback; widget->show_tooltip_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb* callback, void** user_data) @@ -403,7 +403,7 @@ int vc_widget_client_get_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb* cal *callback = widget->show_tooltip_cb; *user_data = widget->show_tooltip_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data) @@ -417,7 +417,7 @@ int vc_widget_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_ch widget->current_lang_changed_cb = callback; widget->current_lang_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb* callback, void** user_data) @@ -431,7 +431,7 @@ int vc_widget_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_ch *callback = widget->current_lang_changed_cb; *user_data = widget->current_lang_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) @@ -445,7 +445,7 @@ int vc_widget_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data widget->error_cb = callback; widget->error_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) @@ -459,7 +459,7 @@ int vc_widget_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_da *callback = widget->error_cb; *user_data = widget->error_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_send_command_list_cb(vc_h vc, vc_widget_send_current_command_list_cb callback, void* user_data) @@ -473,7 +473,7 @@ int vc_widget_client_set_send_command_list_cb(vc_h vc, vc_widget_send_current_co widget->send_command_list_cb = callback; widget->send_command_list_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_send_command_list_cb(vc_h vc, vc_widget_send_current_command_list_cb* callback, void** user_data) @@ -487,7 +487,7 @@ int vc_widget_client_get_send_command_list_cb(vc_h vc, vc_widget_send_current_co *callback = widget->send_command_list_cb; *user_data = widget->send_command_list_user_data; - return 0; + return VC_ERROR_NONE; } @@ -502,7 +502,7 @@ int vc_widget_client_set_service_state(vc_h vc, vc_service_state_e state) widget->service_state = state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_service_state(vc_h vc, vc_service_state_e* state) @@ -515,7 +515,7 @@ int vc_widget_client_get_service_state(vc_h vc, vc_service_state_e* state) *state = widget->service_state; - return 0; + return VC_ERROR_NONE; } @@ -530,7 +530,7 @@ int vc_widget_client_set_state(vc_h vc, vc_state_e state) widget->before_state = widget->current_state; widget->current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_state(vc_h vc, vc_state_e* state) @@ -543,7 +543,7 @@ int vc_widget_client_get_state(vc_h vc, vc_state_e* state) *state = widget->current_state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_state_by_uid(unsigned int uid, vc_state_e* state) @@ -561,13 +561,13 @@ int vc_widget_client_get_state_by_uid(unsigned int uid, vc_state_e* state) if (uid == data->vc->handle) { *state = data->current_state; pthread_mutex_unlock(&g_widget_list_mutex); - return 0; + return VC_ERROR_NONE; } } } pthread_mutex_unlock(&g_widget_list_mutex); - return -1; + return VC_ERROR_INVALID_PARAMETER; } int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) @@ -581,7 +581,7 @@ int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* be *before_state = widget->before_state; *state = widget->current_state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_xid(vc_h vc, int xid) @@ -594,7 +594,7 @@ int vc_widget_client_set_xid(vc_h vc, int xid) widget->xid = xid; - return 0; + return VC_ERROR_NONE; } int vc_widget_cilent_get_xid(vc_h vc, int* xid) @@ -607,7 +607,7 @@ int vc_widget_cilent_get_xid(vc_h vc, int* xid) *xid = widget->xid; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_error(vc_h vc, int reason) @@ -620,7 +620,7 @@ int vc_widget_client_set_error(vc_h vc, int reason) widget->reason = reason; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_error(vc_h vc, int* reason) @@ -633,7 +633,7 @@ int vc_widget_client_get_error(vc_h vc, int* reason) *reason = widget->reason; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_show_tooltip(vc_h vc, bool show) @@ -646,7 +646,7 @@ int vc_widget_client_set_show_tooltip(vc_h vc, bool show) widget->show_tooltip = show; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_show_tooltip(vc_h vc, bool* show) @@ -659,7 +659,7 @@ int vc_widget_client_get_show_tooltip(vc_h vc, bool* show) *show = widget->show_tooltip; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_count() @@ -679,7 +679,7 @@ int vc_widget_client_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; widget->cb_ref_count++; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_not_use_callback(vc_h vc) @@ -691,6 +691,6 @@ int vc_widget_client_not_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; widget->cb_ref_count--; - return 0; + return VC_ERROR_NONE; } diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 54c1df0..8db3d37 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -79,7 +79,7 @@ int __vc_db_reset_handle(void) vc_db_finalize(); vc_db_initialize(); } - return 0; + return VC_DB_ERROR_NONE; } static int __vc_db_transaction(sqlite3* db_handle, const char* transaction) @@ -1731,7 +1731,7 @@ int vc_db_initialize_for_daemon(void) g_ref_cnt++; SLOG(LOG_INFO, vc_db_tag(), "[SUCCESS] DB initialization after restore for daemon"); - return 0; + return VC_DB_ERROR_NONE; } is_connect = __vc_db_connect_db_for_daemon(&g_backup_path, &g_db_backup_handle); @@ -1889,12 +1889,12 @@ int vc_db_finalize(void) } if (!g_db_handle) - return 0; + return VC_DB_ERROR_NONE; db_util_close(g_db_handle); g_db_handle = NULL; if (!g_db_backup_handle) - return 0; + return VC_DB_ERROR_NONE; db_util_close(g_db_backup_handle); g_db_backup_handle = NULL; diff --git a/common/vc_command.c b/common/vc_command.c index 9d7f9d6..3f1b32b 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -87,7 +87,7 @@ static int __vc_cmd_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } static int __check_privilege_initialize() @@ -798,7 +798,7 @@ int vc_cmd_set_id(vc_cmd_h vc_command, int id) cmd->id = id; SLOG(LOG_DEBUG, TAG_VCCMD, "[Set id][%p] id(%d)", vc_command, cmd->id); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_id(vc_cmd_h vc_command, int* id) @@ -821,7 +821,7 @@ int vc_cmd_get_id(vc_cmd_h vc_command, int* id) *id = cmd->id; SLOG(LOG_DEBUG, TAG_VCCMD, "[Get id][%p] id(%d)", vc_command, *id); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_appid(vc_cmd_h vc_command, const char* appid) @@ -849,7 +849,7 @@ int vc_cmd_set_appid(vc_cmd_h vc_command, const char* appid) cmd->appid = strdup(appid); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set appid][%p] appid(%s)", vc_command, cmd->appid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_appid(vc_cmd_h vc_command, char** appid) @@ -873,7 +873,7 @@ int vc_cmd_get_appid(vc_cmd_h vc_command, char** appid) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get appid][%p] appid(%s)", vc_command, *appid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_command(vc_cmd_h vc_command, const char* command) @@ -900,7 +900,7 @@ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set command][%p] Command(%s)", vc_command, cmd->command); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_command(vc_cmd_h vc_command, char** command) @@ -927,7 +927,7 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get command][%p] Command(%s)", vc_command, *command); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command) @@ -953,7 +953,7 @@ int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command) cmd->parameter = strdup(command); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set unfixed command][%p] unfixed command(%s)", vc_command, cmd->parameter); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) @@ -977,7 +977,7 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get unfixed command][%p] unfixed command(%s)", vc_command, *command); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_fixed_command(vc_cmd_h vc_command, const char* fixed) @@ -1005,7 +1005,7 @@ int vc_cmd_set_fixed_command(vc_cmd_h vc_command, const char* fixed) cmd->fixed = strdup(fixed); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set parameter][%p] fixed command(%s)", vc_command, cmd->fixed); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_fixed_command(vc_cmd_h vc_command, char** fixed) @@ -1029,7 +1029,7 @@ int vc_cmd_get_fixed_command(vc_cmd_h vc_command, char** fixed) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get fixed command][%p] fixed command(%s)", vc_command, *fixed); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_invocation_name(vc_cmd_h vc_command, const char* invocation_name) @@ -1057,7 +1057,7 @@ int vc_cmd_set_invocation_name(vc_cmd_h vc_command, const char* invocation_name) cmd->invocation_name = strdup(invocation_name); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set invocation name][%p] invocation_name(%s)", vc_command, cmd->invocation_name); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_invocation_name(vc_cmd_h vc_command, char** invocation_name) @@ -1080,7 +1080,7 @@ int vc_cmd_get_invocation_name(vc_cmd_h vc_command, char** invocation_name) *invocation_name = NULL; SLOG(LOG_DEBUG, TAG_VCCMD, "[Get invocation name][%p] invocation_name(%s)", vc_command, *invocation_name); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_type(vc_cmd_h vc_command, int type) @@ -1104,7 +1104,7 @@ int vc_cmd_set_type(vc_cmd_h vc_command, int type) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set type][%p] type(%d)", vc_command, cmd->type); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_type(vc_cmd_h vc_command, int* type) @@ -1128,7 +1128,7 @@ int vc_cmd_get_type(vc_cmd_h vc_command, int* type) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get type][%p] type(%d)", vc_command, *type); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_format(vc_cmd_h vc_command, int format) @@ -1149,7 +1149,7 @@ int vc_cmd_set_format(vc_cmd_h vc_command, int format) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set format][%p] format(%d)", vc_command, format); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_format(vc_cmd_h vc_command, int* format) @@ -1170,7 +1170,7 @@ int vc_cmd_get_format(vc_cmd_h vc_command, int* format) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get format][%p] format(%d)", vc_command, *format); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_pid(vc_cmd_h vc_command, int pid) @@ -1194,7 +1194,7 @@ int vc_cmd_set_pid(vc_cmd_h vc_command, int pid) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set pid][%p] pid(%d)", vc_command, cmd->pid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid) @@ -1218,7 +1218,7 @@ int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get pid][%p] pid(%d)", vc_command, *pid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_domain(vc_cmd_h vc_command, int domain) @@ -1242,7 +1242,7 @@ int vc_cmd_set_domain(vc_cmd_h vc_command, int domain) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set domain] domain : %d", domain); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain) @@ -1266,7 +1266,7 @@ int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get domain] domain : %d", *domain); - return 0; + return VC_ERROR_NONE; } /** @@ -1301,7 +1301,7 @@ int vc_cmd_set_result_key(vc_cmd_h vc_command, int key, int modifier) SLOG(LOG_DEBUG, TAG_VCCMD, "@@@"); - return 0; + return VC_ERROR_NONE; } /** @@ -1334,7 +1334,7 @@ int vc_cmd_get_result_key(vc_cmd_h vc_command, int* key, int* modifier) SLOG(LOG_DEBUG, TAG_VCCMD, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_cmd_print_list(vc_cmd_list_h vc_cmd_list) @@ -1367,7 +1367,7 @@ int vc_cmd_print_list(vc_cmd_list_h vc_cmd_list) SLOG(LOG_DEBUG, TAG_VCCMD, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json) @@ -1394,7 +1394,7 @@ int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json) return VC_ERROR_OPERATION_FAILED; } - return 0; + return VC_ERROR_NONE; } static void __vc_cmd_regex_deinit(int num_regex) diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 5436e46..aa391d3 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -124,7 +124,7 @@ int __vc_config_mgr_check_engine_is_valid(const char* engine_id) if (!strcmp(engine_id, engine_info->uuid)) { SLOG(LOG_DEBUG, vc_config_tag(), "Default engine is valid : %s", engine_id); - return 0; + return VC_ERROR_NONE; } iter = g_slist_next(iter); @@ -164,7 +164,7 @@ int __vc_config_mgr_check_engine_is_valid(const char* engine_id) return -1; } - return 0; + return VC_ERROR_NONE; } bool __vc_config_mgr_check_lang_is_valid(const char* engine_id, const char* language) @@ -425,7 +425,7 @@ int __vc_config_mgr_get_engine_info() return -1; } - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_config_mgr_engine_config_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler) @@ -540,7 +540,7 @@ static int __vc_config_mgr_register_engine_config_updated_event(const char* path g_ino_list = g_list_append(g_ino_list, ino); pthread_mutex_unlock(&vc_config_engine_mutex); - return 0; + return VC_ERROR_NONE; } static int __vc_config_mgr_unregister_engine_config_updated_event() @@ -569,7 +569,7 @@ static int __vc_config_mgr_unregister_engine_config_updated_event() } } pthread_mutex_unlock(&vc_config_engine_mutex); - return 0; + return VC_ERROR_NONE; } Eina_Bool vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler) @@ -725,7 +725,7 @@ int __vc_config_set_auto_language() if (0 == strncmp(g_config_info->language, candidate_lang, 5)) { SLOG(LOG_DEBUG, vc_config_tag(), "[Config] VC language(%s) is same with display language", g_config_info->language); - return 0; + return VC_ERROR_NONE; } if (true == __vc_config_mgr_check_lang_is_valid(g_config_info->engine_id, candidate_lang)) { @@ -813,7 +813,7 @@ int __vc_config_set_auto_language() if (NULL != before_lang) free(before_lang); } - return 0; + return VC_ERROR_NONE; } void __vc_config_language_changed_cb(keynode_t *key, void *data) @@ -850,7 +850,7 @@ int vc_config_mgr_initialize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } iter = g_slist_next(iter); @@ -878,7 +878,7 @@ int vc_config_mgr_initialize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } /* Get file name from default engine directory */ @@ -1041,7 +1041,7 @@ int vc_config_mgr_initialize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_finalize(unsigned int uid) @@ -1054,7 +1054,7 @@ int vc_config_mgr_finalize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } __vc_config_release_engine(); @@ -1070,7 +1070,7 @@ int vc_config_mgr_finalize(unsigned int uid) SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); SLOG(LOG_DEBUG, vc_config_tag(), "[Success] Finalize config"); - return 0; + return VC_ERROR_NONE; } @@ -1108,7 +1108,7 @@ int __vc_config_mgr_register_lang_event() } g_lang_ref_count++; - return 0; + return VC_ERROR_NONE; } int __vc_config_mgr_unregister_config_event() @@ -1130,7 +1130,7 @@ int __vc_config_mgr_unregister_config_event() vconf_ignore_key_changed(VCONFKEY_LANGSET, __vc_config_language_changed_cb); } - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb engine_cb) @@ -1162,7 +1162,7 @@ int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb en pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_unset_engine_cb(unsigned int uid) @@ -1190,7 +1190,7 @@ int vc_config_mgr_unset_engine_cb(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } @@ -1223,7 +1223,7 @@ int vc_config_mgr_set_lang_cb(unsigned int uid, vc_config_lang_changed_cb lang_c pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_unset_lang_cb(unsigned int uid) @@ -1251,7 +1251,7 @@ int vc_config_mgr_unset_lang_cb(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_enabled_cb(unsigned int uid, vc_config_enabled_cb enabled_cb) @@ -1303,7 +1303,7 @@ int vc_config_mgr_unset_enabled_cb(unsigned int uid) if (uid == temp_client->uid) { temp_client->enabled_cb = NULL; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } } iter = g_slist_next(iter); @@ -1331,7 +1331,7 @@ int vc_config_mgr_get_auto_language(bool* value) *value = g_config_info->auto_lang; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_auto_language(bool value) @@ -1360,7 +1360,7 @@ int vc_config_mgr_set_auto_language(bool value) } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_get_engine_list(vc_config_supported_engine_cb callback, void* user_data) @@ -1516,7 +1516,7 @@ int vc_config_mgr_set_engine(const char* engine) /* Check current engine id with new engine id */ if (0 == strncmp(g_config_info->engine_id, engine, strlen(g_config_info->engine_id))) { pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } SLOG(LOG_DEBUG, vc_config_tag(), "New engine id : %s", engine); @@ -1683,7 +1683,7 @@ int vc_config_mgr_get_language_list(vc_supported_language_cb callback, void* use } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_get_default_language(char** language) @@ -1709,7 +1709,7 @@ int vc_config_mgr_get_default_language(char** language) } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } static int __vc_config_mgr_set_default_language(const char* language) @@ -1736,7 +1736,7 @@ static int __vc_config_mgr_set_default_language(const char* language) return -1; } - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_default_language(const char* language) @@ -1765,7 +1765,7 @@ int vc_config_mgr_get_enabled(bool* value) *value = g_config_info->enabled; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_enabled(bool value) @@ -1786,7 +1786,7 @@ int vc_config_mgr_set_enabled(bool value) g_config_info->enabled = value; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_get_nonfixed_support(bool* value) @@ -1836,7 +1836,7 @@ int vc_config_mgr_get_nonfixed_support(bool* value) } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } bool vc_config_check_default_engine_is_valid(const char* engine) @@ -1980,7 +1980,7 @@ int __vc_config_mgr_print_engine_info() SLOG(LOG_DEBUG, vc_config_tag(), "@ engine list @"); SLOG(LOG_DEBUG, vc_config_tag(), " No Engine in engine directory"); SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } /* Get a first item */ @@ -2023,7 +2023,7 @@ int __vc_config_mgr_print_engine_info() } SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } int __vc_config_mgr_print_client_info() @@ -2035,7 +2035,7 @@ int __vc_config_mgr_print_client_info() SLOG(LOG_DEBUG, vc_config_tag(), "@ Client list @"); SLOG(LOG_DEBUG, vc_config_tag(), " No Client"); SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } /* Get a first item */ @@ -2054,5 +2054,5 @@ int __vc_config_mgr_print_client_info() } SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 267c7c6..404d52f 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -69,14 +69,14 @@ int vcd_client_manager_set(int pid) int ret = app_manager_get_app_id(pid, &appid); if (0 != ret || NULL == appid) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] fail to get app id, ret(%d), pid(%d)", ret, pid); - return -1; + return VCD_ERROR_OPERATION_FAILED; } if (-1 != g_manager.pid && NULL != g_manager.appid && 0 == strncmp(g_manager.appid, appid, strlen(g_manager.appid))) { SLOG(LOG_WARN, TAG_VCD, "Same manager has already registered. It doesn't need to set manager again."); if (appid) free(appid); - return 0; + return VCD_ERROR_NONE; } g_manager.pid = pid; @@ -88,7 +88,7 @@ int vcd_client_manager_set(int pid) free(appid); appid = NULL; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_unset() @@ -97,7 +97,7 @@ int vcd_client_manager_unset() g_manager.manager_cmd = false; g_manager.exclusive_cmd_option = false; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_unset_appid() @@ -106,7 +106,7 @@ int vcd_client_manager_unset_appid() free(g_manager.appid); g_manager.appid = NULL; } - return 0; + return VCD_ERROR_NONE; } bool vcd_client_manager_is_valid(int pid) @@ -121,20 +121,20 @@ int vcd_client_manager_set_command(int pid) { if (pid != g_manager.pid) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_manager.manager_cmd = true; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_unset_command(int pid) { if (pid != g_manager.pid) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_manager.manager_cmd = false; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_manager_is_system_command_valid(int pid) @@ -173,7 +173,7 @@ int vcd_client_manager_set_demandable_client(int pid, GSList* client_list) g_demandable_client = client_list; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_manager_check_demandable_client(int pid) @@ -230,7 +230,7 @@ bool vcd_client_manager_get_exclusive() int vcd_client_manager_set_exclusive(bool value) { g_manager.exclusive_cmd_option = value; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_get_pid() @@ -243,7 +243,7 @@ int vcd_client_manager_get_appid(char** appid) if (NULL != g_manager.appid) *appid = strdup(g_manager.appid); - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_set_result_text(const char* result) @@ -257,7 +257,7 @@ int vcd_client_manager_set_result_text(const char* result) g_result_text = strdup(result); } - return 0; + return VCD_ERROR_NONE; } char* vcd_client_manager_get_result_text() @@ -392,7 +392,7 @@ int vcd_client_manager_delete_tidl_info() free(g_mgr_tidl_info); g_mgr_tidl_info = NULL; - return 0; + return VCD_ERROR_NONE; } manager_tidl_info_s* vcd_client_manager_get_tidl_info() @@ -454,7 +454,7 @@ int __vcd_client_release_commands() __vcd_client_release_each_commands(&(g_cur_cmd_list.foreground_cmds)); __vcd_client_release_each_commands(&(g_cur_cmd_list.background_cmds)); - return 0; + return VCD_ERROR_NONE; } int vcd_client_command_collect_command() @@ -488,7 +488,7 @@ int vcd_client_command_collect_command() SLOG(LOG_INFO, TAG_VCD, "[Client Data] No exclusive system commands"); } - return 0; + return VCD_ERROR_NONE; } /* 3. Set system command */ @@ -572,7 +572,7 @@ int vcd_client_command_collect_command() g_cur_cmd_list.background_cmds = bg_cmd_list; } } - return 0; + return VCD_ERROR_NONE; } int vcd_client_get_length() @@ -707,7 +707,7 @@ int vcd_client_foreach_command(client_foreach_command_cb callback, void* user_da } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data] No background commands"); } - return 0; + return VCD_ERROR_NONE; } static vc_cmd_s* __command_copy(vc_cmd_s* src_cmd) @@ -783,7 +783,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -806,7 +806,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -826,7 +826,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -846,7 +846,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -866,7 +866,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -885,7 +885,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) if (result_id == temp_cmd->id) { *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -895,13 +895,13 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) } SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Not find matched result"); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } int vcd_client_set_slience_detection(bool value) { g_silence_detection = value; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_get_slience_detection() @@ -912,7 +912,7 @@ bool vcd_client_get_slience_detection() int vcd_client_set_recognition_mode(vcd_recognition_mode_e mode) { g_recognition_mode = mode; - return 0; + return VCD_ERROR_NONE; } vcd_recognition_mode_e vcd_client_get_recognition_mode() @@ -933,7 +933,7 @@ int vcd_client_set_server_dialog(int pid, bool is_server_dialog) client_info->server_dialog = is_server_dialog; SLOG(LOG_INFO, TAG_VCD, "[Client Data] Set server dialog, client pid(%d), server_dialog(%d)", pid, client_info->server_dialog); - return 0; + return VCD_ERROR_NONE; } int vcd_client_get_server_dialog(int pid, bool* is_server_dialog) @@ -949,7 +949,7 @@ int vcd_client_get_server_dialog(int pid, bool* is_server_dialog) *is_server_dialog = client_info->server_dialog; SLOG(LOG_INFO, TAG_VCD, "[Client Data] Get server dialog, client pid(%d), server_dialog(%d)", pid, *is_server_dialog); - return 0; + return VCD_ERROR_NONE; } int vcd_client_append_cmd_from_type(int type, vc_cmd_list_h list) @@ -1009,7 +1009,7 @@ int vcd_client_append_cmd_from_type(int type, vc_cmd_list_h list) item = item->next; } - return 0; + return VCD_ERROR_NONE; } int __show_client_list() @@ -1066,7 +1066,7 @@ int __show_client_list() SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return 0; + return VCD_ERROR_NONE; } int __show_command_list(GSList* cmd_group) @@ -1101,7 +1101,7 @@ int __show_command_list(GSList* cmd_group) SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return 0; + return VCD_ERROR_NONE; } GSList* __client_get_item(const int pid) @@ -1192,7 +1192,7 @@ int vcd_client_add(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client"); } @@ -1200,7 +1200,7 @@ int vcd_client_add(int pid) #ifdef CLIENT_DATA_DEBUG __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } int vcd_client_delete(int pid) @@ -1229,7 +1229,7 @@ int vcd_client_delete(int pid) __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } GSList* __get_client_tidl_info_item(const int pid) @@ -1318,7 +1318,7 @@ int vcd_client_add_tidl_info(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client tidl info. pid(%d)", pid); } @@ -1441,7 +1441,7 @@ int vcd_client_delete_tidl_info(int pid) /*Delete handle from list*/ g_client_tidl_info_list = g_slist_delete_link(g_client_tidl_info_list, tmp); - return 0; + return VCD_ERROR_NONE; } client_tidl_info_s* vcd_client_get_tidl_info(int pid) @@ -1452,12 +1452,12 @@ client_tidl_info_s* vcd_client_get_tidl_info(int pid) int vcd_client_get_tidl_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_client_tidl_info_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -1486,7 +1486,7 @@ int vcd_client_get_tidl_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_is_available(int pid) @@ -1519,12 +1519,12 @@ int vcd_client_get_ref_count() int vcd_client_get_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_client_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -1553,7 +1553,7 @@ int vcd_client_get_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } int vcd_client_set_command_type(int pid, int type) @@ -1575,10 +1575,10 @@ int vcd_client_set_command_type(int pid, int type) break; default: SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] not supported command type(%d)", type); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } - return 0; + return VCD_ERROR_NONE; } int vcd_client_unset_command_type(int pid, int type) @@ -1600,10 +1600,10 @@ int vcd_client_unset_command_type(int pid, int type) break; default: SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] not supported command type(%d)", type); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } - return 0; + return VCD_ERROR_NONE; } int vcd_client_set_exclusive_command(int pid) @@ -1618,7 +1618,7 @@ int vcd_client_set_exclusive_command(int pid) client_info->exclusive_cmd = true; - return 0; + return VCD_ERROR_NONE; } int vcd_client_unset_exclusive_command(int pid) @@ -1633,17 +1633,17 @@ int vcd_client_unset_exclusive_command(int pid) client_info->exclusive_cmd = false; - return 0; + return VCD_ERROR_NONE; } int vcd_client_save_client_info() { if (0 != vc_info_parser_set_client_info(g_client_list)) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to save client info"); - return -1; + return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } /* @@ -1709,12 +1709,12 @@ widget_info_s* __widget_get_element(int pid) int vcd_client_widget_get_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_widget_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -1742,7 +1742,7 @@ int vcd_client_widget_get_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_add(int pid) @@ -1774,7 +1774,7 @@ int vcd_client_widget_add(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new widget"); } @@ -1782,7 +1782,7 @@ int vcd_client_widget_add(int pid) #ifdef CLIENT_DATA_DEBUG __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_delete(int pid) @@ -1811,7 +1811,7 @@ int vcd_client_widget_delete(int pid) __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_get_foreground_pid() @@ -1828,7 +1828,7 @@ int vcd_client_widget_get_foreground_pid() widget = __widget_get_element(fg_pid); if (NULL == widget) { SLOG(LOG_WARN, TAG_VCD, "[Client Data] Not found foreground pid of widget"); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } return widget->pid; @@ -1859,7 +1859,7 @@ int vcd_client_widget_set_command(int pid) info->widget_cmd = true; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_unset_command(int pid) @@ -1873,7 +1873,7 @@ int vcd_client_widget_unset_command(int pid) info->widget_cmd = false; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_set_asr_result_enabled(int pid, bool enable) @@ -1887,7 +1887,7 @@ int vcd_client_widget_set_asr_result_enabled(int pid, bool enable) info->asr_result_enabled = enable; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) @@ -1901,7 +1901,7 @@ int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) *enable = info->asr_result_enabled; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting) @@ -1909,25 +1909,25 @@ int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting) if (TRUE == waiting && pid != vcd_client_widget_get_foreground_pid()) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT foreground pid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_is_waiting_recording = waiting; g_waiting_recording_pid = pid; SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to set waiting for recording, pid(%d), waiting(%d)", pid, waiting); - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_get_waiting_for_recording(int pid, bool* waiting) { if (pid != g_waiting_recording_pid) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT waiting pid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } *waiting = g_is_waiting_recording; SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to get waiting for recording, waiting(%d)", *waiting); - return 0; + return VCD_ERROR_NONE; } GSList* __get_widget_tidl_info_item(const int pid) @@ -2018,7 +2018,7 @@ int vcd_client_widget_add_tidl_info(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new widget tidl info. pid(%d)", pid); } @@ -2094,7 +2094,7 @@ int vcd_client_widget_delete_tidl_info(int pid) /*Delete handle from list*/ g_widget_tidl_info_list = g_slist_delete_link(g_widget_tidl_info_list, tmp); - return 0; + return VCD_ERROR_NONE; } widget_tidl_info_s* vcd_client_widget_get_tidl_info(int pid) @@ -2271,7 +2271,7 @@ int vcd_client_setting_add_tidl_info(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Setting Data SUCCESS] Add new setting client tidl info. pid(%d)", pid); } @@ -2347,7 +2347,7 @@ int vcd_client_setting_delete_tidl_info(int pid) /*Delete handle from list*/ g_setting_tidl_info_list = g_slist_delete_link(g_setting_tidl_info_list, tmp); - return 0; + return VCD_ERROR_NONE; } setting_tidl_info_s* vcd_client_setting_get_tidl_info(int pid) @@ -2358,12 +2358,12 @@ setting_tidl_info_s* vcd_client_setting_get_tidl_info(int pid) int vcd_client_setting_get_tidl_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_setting_tidl_info_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -2392,5 +2392,5 @@ int vcd_client_setting_get_tidl_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } diff --git a/server/vcd_config.c b/server/vcd_config.c index cdf2f3d..2cfa477 100644 --- a/server/vcd_config.c +++ b/server/vcd_config.c @@ -69,7 +69,7 @@ int vcd_config_initialize(vcd_config_lang_changed_cb lang_cb, vcd_config_foregro g_foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; - return 0; + return VCD_ERROR_NONE; } int vcd_config_finalize() @@ -77,7 +77,7 @@ int vcd_config_finalize() vc_config_mgr_unset_lang_cb(getpid()); vc_config_mgr_finalize(getpid()); - return 0; + return VCD_ERROR_NONE; } int vcd_config_get_default_language(char** language) @@ -90,7 +90,7 @@ int vcd_config_get_default_language(char** language) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_default_language(const char* language) @@ -103,7 +103,7 @@ int vcd_config_set_default_language(const char* language) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_service_state(vcd_state_e state) @@ -112,7 +112,7 @@ int vcd_config_set_service_state(vcd_state_e state) SLOG(LOG_INFO, TAG_VCD, "[Config] Config is changed : %d", g_state); - return 0; + return VCD_ERROR_NONE; } vcd_state_e vcd_config_get_service_state() @@ -123,7 +123,7 @@ vcd_state_e vcd_config_get_service_state() int vcd_config_get_foreground(int* pid) { *pid = g_foreground_pid; - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_foreground(int pid, bool value) @@ -135,7 +135,7 @@ int vcd_config_set_foreground(int pid, bool value) g_foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; } } - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_disabled_command_type(int disabled_cmd_type) @@ -144,35 +144,35 @@ int vcd_config_set_disabled_command_type(int disabled_cmd_type) g_disabled_command_type = disabled_cmd_type; - return 0; + return VCD_ERROR_NONE; } int vcd_config_get_command_type_enabled(int cmd_type) { if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type"); - return 0; + return VCD_ERROR_NONE; } if (~(g_disabled_command_type) & (1 << cmd_type)) return 1; else - return 0; + return VCD_ERROR_NONE; } int vcd_config_get_audio_streaming_mode(vcd_audio_streaming_mode_e* streaming_mode) { *streaming_mode = g_audio_streaming_mode; - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_audio_streaming_mode(vcd_audio_streaming_mode_e streaming_mode) { if (streaming_mode < VCD_AUDIO_STREAMING_MODE_VC_SERVICE || streaming_mode > VCD_AUDIO_STREAMING_MODE_OUTSIDE) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid streaming mode(%d)", streaming_mode); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_audio_streaming_mode = streaming_mode; - return 0; + return VCD_ERROR_NONE; } diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 2d5bcf2..9c3c9c1 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -122,7 +122,7 @@ int vcd_engine_agent_init() SLOG(LOG_INFO, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent Initialize"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_release() @@ -160,7 +160,7 @@ int vcd_engine_agent_release() SLOG(LOG_INFO, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent release"); - return 0; + return VCD_ERROR_NONE; } bool vcd_engine_is_available_engine() @@ -249,7 +249,7 @@ static int __internal_get_engine_info(vce_request_callback_s* callback) SLOG(LOG_INFO, TAG_VCD, "Engine setting : %s", g_dynamic_engine.engine_setting_path); SLOG(LOG_INFO, TAG_VCD, "@@@"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) @@ -268,7 +268,7 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) if (true == g_dynamic_engine.is_loaded) { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Engine has already been loaded"); - return 0; + return VCD_ERROR_NONE; } /* Get current engine info */ @@ -329,7 +329,7 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] load current engine FINISH"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_unload_current_engine() @@ -354,7 +354,7 @@ int vcd_engine_agent_unload_current_engine() /* reset current engine data */ g_dynamic_engine.is_loaded = false; - return 0; + return VCD_ERROR_NONE; } @@ -386,7 +386,7 @@ int vcd_engine_set_commands() SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] Dynamic engine is not available"); } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_start(bool silence) @@ -411,7 +411,7 @@ int vcd_engine_recognize_start(bool silence) } SLOG(LOG_INFO, TAG_VCD, "[Engine Agent SUCCESS] Engine start"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_audio(const void* data, unsigned int length, vce_speech_detect_e* speech_detected) @@ -439,7 +439,7 @@ int vcd_engine_recognize_audio(const void* data, unsigned int length, vce_speech } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_stop() @@ -461,7 +461,7 @@ int vcd_engine_recognize_stop() return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_cancel() @@ -480,7 +480,7 @@ int vcd_engine_recognize_cancel() } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_audio_type(const char* audio) @@ -499,7 +499,7 @@ int vcd_engine_set_audio_type(const char* audio) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_server_dialog(const char* app_id, const char* credential) @@ -518,7 +518,7 @@ int vcd_engine_set_server_dialog(const char* app_id, const char* credential) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_domain(int pid, const char* domain) @@ -537,7 +537,7 @@ int vcd_engine_set_domain(int pid, const char* domain) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_get_nlu_base_info(int pid, const char* key, char** value) @@ -564,7 +564,7 @@ int vcd_engine_get_nlu_base_info(int pid, const char* key, char** value) return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_private_data(int pid, const char* key, const char* data) @@ -589,7 +589,7 @@ int vcd_engine_set_private_data(int pid, const char* key, const char* data) return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_get_private_data(int pid, const char* key, char** data) @@ -616,7 +616,7 @@ int vcd_engine_get_private_data(int pid, const char* key, char** data) return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request) @@ -638,7 +638,7 @@ int vcd_engine_send_specific_engine_request(const char* engine_app_id, const cha return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_process_text(int pid, const char* text) @@ -657,7 +657,7 @@ int vcd_engine_process_text(int pid, const char* text) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_process_list_event(int pid, const char* event) @@ -676,7 +676,7 @@ int vcd_engine_process_list_event(int pid, const char* event) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_process_haptic_event(int pid, const char* event) @@ -695,7 +695,7 @@ int vcd_engine_process_haptic_event(int pid, const char* event) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_request_tts(int pid, int utt_id, const char* text, const char* language) @@ -719,7 +719,7 @@ int vcd_engine_request_tts(int pid, int utt_id, const char* text, const char* la return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_cancel_tts(int pid, int utt_id) @@ -741,7 +741,7 @@ int vcd_engine_cancel_tts(int pid, int utt_id) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_get_tts_audio_format(int* rate, int* channel, int* audio_type) @@ -763,7 +763,7 @@ int vcd_engine_get_tts_audio_format(int* rate, int* channel, int* audio_type) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } @@ -788,7 +788,7 @@ int vcd_engine_get_audio_format(const char* audio_id, vce_audio_type_e* types, i return ret; } - return 0; + return VCD_ERROR_NONE; } static bool __supported_language_cb(const char* language, void* user_data) @@ -826,7 +826,7 @@ int vcd_engine_supported_langs(GList** lang_list) return ret; } - return 0; + return VCD_ERROR_NONE; } @@ -845,7 +845,7 @@ int vcd_engine_get_current_language(char** lang) /* get default language */ *lang = g_strdup(g_default_lang); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_current_language(const char* language) @@ -873,7 +873,7 @@ int vcd_engine_set_current_language(const char* language) SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] Dynamic engine is not available (Cannot start)"); } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data) @@ -887,7 +887,7 @@ int vcd_engine_agent_get_command_count(vce_cmd_h vce_command, int* count) SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] Request command length from engine"); *count = vcd_client_get_length(); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_get_audio_type(char** audio_type) diff --git a/server/vcd_server.c b/server/vcd_server.c index d82b10b..16717a5 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -131,7 +131,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt if (VCD_STATE_READY == state) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Ready state, but recording"); } else if (VCD_STATE_PROCESSING == state) { - return 0; + return VCD_ERROR_NONE; } vce_speech_detect_e speech_detected = VCE_SPEECH_DETECT_NONE; @@ -149,7 +149,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt } else { vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), ret, "voice_framework.error.engine.set_recording_fail"); } - return 0; + return VCD_ERROR_NONE; } if (VCE_SPEECH_DETECT_BEGIN == speech_detected) { @@ -182,7 +182,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt } } - return 0; + return VCD_ERROR_NONE; } void __server_recorder_interrupt_callback() @@ -1363,7 +1363,7 @@ int vcd_initialize(vce_request_callback_s *callback) SLOG(LOG_ERROR, TAG_VCD, "[Server SUCCESS] initialize"); - return 0; + return VCD_ERROR_NONE; } bool vcd_finalize() @@ -1844,7 +1844,7 @@ static int __reset_waiting_for_widget_recording(void) } // Reset flag to wait for recording from widget client vcd_client_widget_set_waiting_for_recording(-1, false); - return 0; + return VCD_ERROR_NONE; } #if 0 @@ -1885,7 +1885,7 @@ static int __set_waiting_for_widget_recording(int pid) // Set flag to wait for recording from widget client vcd_client_widget_set_waiting_for_recording(pid, true); - return 0; + return VCD_ERROR_NONE; } static int __start_internal_recognition() @@ -1954,7 +1954,7 @@ static int __start_internal_recognition() SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence); - return 0; + return VCD_ERROR_NONE; } static Eina_Bool __vcd_request_show_tooltip(void *data) @@ -1996,7 +1996,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); __set_waiting_for_widget_recording(pid); - return 0; + return VCD_ERROR_NONE; } } } else { @@ -2446,7 +2446,7 @@ int vcd_server_set_command(int pid, vc_cmd_type_e cmd_type) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_server_unset_command(int pid, vc_cmd_type_e cmd_type) @@ -2462,7 +2462,7 @@ int vcd_server_unset_command(int pid, vc_cmd_type_e cmd_type) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_server_set_foreground(int pid, bool value) @@ -2478,7 +2478,7 @@ int vcd_server_set_foreground(int pid, bool value) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } static int __vcd_server_launch_manager_app() @@ -2556,7 +2556,7 @@ int vcd_server_set_server_dialog(int pid, const char* app_id, const char* creden SLOG(LOG_INFO, TAG_VCD, "[Server] Set to false for server dialog, app_id(%s)", app_id); } - return 0; + return VCD_ERROR_NONE; } int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int continuous) @@ -2590,7 +2590,7 @@ int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int return ret; } } - return 0; + return VCD_ERROR_NONE; } int vcd_server_is_system_command_valid(int pid, int* is_sys_cmd_valid) @@ -2607,7 +2607,7 @@ int vcd_server_is_system_command_valid(int pid, int* is_sys_cmd_valid) else *is_sys_cmd_valid = false; - return 0; + return VCD_ERROR_NONE; } static void __start_tts_request_thread(void* data, Ecore_Thread* thread) @@ -2715,7 +2715,7 @@ int vcd_server_request_tts(int pid, const char* text, const char* language, int g_tts_thread = ecore_thread_run(__start_tts_request_thread, __end_tts_request_thread, NULL, NULL); } - return 0; + return VCD_ERROR_NONE; } int vcd_server_cancel_tts(int pid, int utt_id) @@ -2808,7 +2808,7 @@ int vcd_server_set_exclusive_command(int pid, bool value) } } - return 0; + return VCD_ERROR_NONE; } int vcd_server_request_start(int pid, bool stop_by_silence) @@ -2843,7 +2843,7 @@ int vcd_server_request_start(int pid, bool stop_by_silence) return VCD_ERROR_INVALID_PARAMETER; } - return 0; + return VCD_ERROR_NONE; } int vcd_server_request_stop(int pid) @@ -2949,7 +2949,7 @@ int vcd_server_widget_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty, vc-service will be terminated"); ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); - return 0; + return VCD_ERROR_NONE; } return VCD_ERROR_INVALID_PARAMETER; } @@ -2962,7 +2962,7 @@ int vcd_server_widget_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty, vc-service will be terminated"); ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); - return 0; + return VCD_ERROR_NONE; } bool is_waiting = false; @@ -2988,7 +2988,7 @@ int vcd_server_widget_start_recording(int pid, bool widget_command) bool waiting; if (0 != vcd_client_widget_get_waiting_for_recording(pid, &waiting) || false == waiting) { SLOG(LOG_ERROR, TAG_VCD, "[Server] Server is not waiting for recording, pid(%d), waiting(%d)", pid, waiting); - return 0; + return VCD_ERROR_NONE; } if (true == widget_command) { @@ -3006,7 +3006,7 @@ int vcd_server_widget_start_recording(int pid, bool widget_command) ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false); } - return 0; + return VCD_ERROR_NONE; } int vcd_server_widget_start(int pid, bool stop_by_silence) @@ -3032,7 +3032,7 @@ int vcd_server_widget_start(int pid, bool stop_by_silence) /* Notify show tooltip */ ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); - return 0; + return VCD_ERROR_NONE; } int vcd_server_widget_stop(int pid) @@ -3255,7 +3255,7 @@ int vcd_send_update_status(vce_update_event_e update_event, const char* msg) SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Update event : Fail - msg(%s)", msg); } - return 0; + return VCD_ERROR_NONE; } int vcd_set_private_data_set_cb(vce_private_data_set_cb callback_func) diff --git a/server/vcd_server_data.cpp b/server/vcd_server_data.cpp index 7a238aa..579928a 100644 --- a/server/vcd_server_data.cpp +++ b/server/vcd_server_data.cpp @@ -121,7 +121,7 @@ int vcd_data_get_tts_text_data(unsigned int tts_uid, vc_tts_text_data_s** data) SLOG(LOG_ERROR, TAG_VCD, "[DATA ERROR] There is no tts_text data"); *data = NULL; pthread_mutex_unlock(&g_tts_text_data_mutex); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } std::list::iterator iter; @@ -159,7 +159,7 @@ int vcd_data_get_first_tts_text_data(vc_tts_text_data_s** data) SLOG(LOG_ERROR, TAG_VCD, "[DATA ERROR] There is no tts_text data"); *data = NULL; pthread_mutex_unlock(&g_tts_text_data_mutex); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } std::list::iterator iter; diff --git a/server/vce.c b/server/vce.c index 9a66d2d..be70147 100644 --- a/server/vce.c +++ b/server/vce.c @@ -58,7 +58,7 @@ static int __vce_get_feature_enabled() } } - return 0; + return VCE_ERROR_NONE; } static int __check_privilege_initialize() @@ -177,7 +177,7 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) SLOG(LOG_DEBUG, TAG_VCD, " "); SLOG(LOG_DEBUG, TAG_VCD, " "); - return 0; + return VCE_ERROR_NONE; } int vce_send_result(vce_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, void *user_data) -- 2.7.4 From d7084335c138e9219c18523f7f763f4ebb9424c0 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 29 Jun 2022 17:39:17 +0900 Subject: [PATCH 03/16] Unify bundle data in client, mgr, and widget Change-Id: If822325a6edfcc6d6ea6fdf65229455fb8f081f6 Signed-off-by: sooyeon --- client/vc_mgr_tidl.c | 56 +++++----- client/vc_setting_tidl.c | 11 +- client/vc_tidl.c | 4 +- client/vc_widget_tidl.c | 16 +-- common/vc_defs.h | 48 ++++----- server/vcd_tidl.c | 266 ++++++++++++++++++++++++----------------------- 6 files changed, 193 insertions(+), 208 deletions(-) diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index 7376fd5..eaa5ddf 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -97,10 +97,10 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_DEBUG, TAG_VCM, "__notify_cb is invoked"); - bundle_get_str(msg, VC_MANAGER_BUNDLE_METHOD, &method); + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_MANAGER_METHOD_SET_VOLUME, method, strlen(VCD_MANAGER_METHOD_SET_VOLUME))) { - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_VOLUME, &val); float volume = 0; if (val) { @@ -119,7 +119,7 @@ static void __notify_cb(void *user_data, bundle *msg) } /* VCD_MANAGER_METHOD_SET_VOLUME */ else if (0 == strncmp(VCD_MANAGER_METHOD_SET_SERVICE_STATE, method, strlen(VCD_MANAGER_METHOD_SET_SERVICE_STATE))) { - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val); int state = 0; if (val) { state = atoi(val); @@ -139,7 +139,7 @@ static void __notify_cb(void *user_data, bundle *msg) else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT))) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get All Result"); - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_RESULT, &val); if (val) { __vc_mgr_cb_all_result((vc_result_type_e)atoi(val)); @@ -153,8 +153,8 @@ static void __notify_cb(void *user_data, bundle *msg) char* event = NULL; char* pre_result = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_EVENT, &event); - bundle_get_str(msg, VC_MANAGER_BUNDLE_PRE_RESULT, &pre_result); + bundle_get_str(msg, VC_BUNDLE_EVENT, &event); + bundle_get_str(msg, VC_BUNDLE_PRE_RESULT, &pre_result); if (NULL != pre_result) { __vc_mgr_cb_pre_result((vc_pre_result_event_e)atoi(event), pre_result); @@ -169,9 +169,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* event = NULL; char* result = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_ENGINE_APP_ID, &engine_app_id); - bundle_get_str(msg, VC_MANAGER_BUNDLE_EVENT, &event); - bundle_get_str(msg, VC_MANAGER_BUNDLE_RESULT, &result); + bundle_get_str(msg, VC_BUNDLE_ENGINE_APP_ID, &engine_app_id); + bundle_get_str(msg, VC_BUNDLE_EVENT, &event); + bundle_get_str(msg, VC_BUNDLE_RESULT, &result); if (NULL != result) { gsize decodingSize=0; @@ -201,10 +201,10 @@ static void __notify_cb(void *user_data, bundle *msg) char* utt_text = NULL; char* continous = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &pid); - bundle_get_str(msg, VC_MANAGER_BUNDLE_DISP_TEXT, &disp_text); - bundle_get_str(msg, VC_MANAGER_BUNDLE_UTT_TEXT, &utt_text); - bundle_get_str(msg, VC_MANAGER_BUNDLE_CONTINUOUS, &continous); + bundle_get_str(msg, VC_BUNDLE_PID, &pid); + bundle_get_str(msg, VC_BUNDLE_DISP_TEXT, &disp_text); + bundle_get_str(msg, VC_BUNDLE_UTT_TEXT, &utt_text); + bundle_get_str(msg, VC_BUNDLE_CONTINUOUS, &continous); if (!strncmp(disp_text, "#NULL", strlen("#NULL") + 1)) disp_text = NULL; @@ -222,9 +222,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* daemon_pid = NULL; char* err_msg = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_REASON, &reason); - bundle_get_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, &daemon_pid); - bundle_get_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, &err_msg); + bundle_get_str(msg, VC_BUNDLE_REASON, &reason); + bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &daemon_pid); + bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg); char* temp_msg = NULL; if (NULL != err_msg && strncmp(err_msg, "#NULL", strlen("#NULL") + 1)) { @@ -246,9 +246,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* key = NULL; char* private_data = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &pid); - bundle_get_str(msg, VC_MANAGER_BUNDLE_KEY, &key); - bundle_get_str(msg, VC_MANAGER_BUNDLE_PRIVATE_DATA, &private_data); + bundle_get_str(msg, VC_BUNDLE_PID, &pid); + bundle_get_str(msg, VC_BUNDLE_KEY, &key); + bundle_get_str(msg, VC_BUNDLE_PRIVATE_DATA, &private_data); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request set private data : pid(%d) ", atoi(pid)); if (pid > 0) { @@ -266,9 +266,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* audio_type = NULL; char* rate = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_AUDIO_CHANNEL, &channel); - bundle_get_str(msg, VC_MANAGER_BUNDLE_AUDIO_TYPE, &audio_type); - bundle_get_str(msg, VC_MANAGER_BUNDLE_AUDIO_RATE, &rate); + bundle_get_str(msg, VC_BUNDLE_AUDIO_CHANNEL, &channel); + bundle_get_str(msg, VC_BUNDLE_AUDIO_TYPE, &audio_type); + bundle_get_str(msg, VC_BUNDLE_AUDIO_RATE, &rate); __vc_mgr_cb_feedback_audio_format(atoi(rate), (vc_audio_channel_e)atoi(channel), (vc_audio_type_e)atoi(audio_type)); @@ -284,8 +284,8 @@ static void __notify_cb(void *user_data, bundle *msg) // int pid = 0; // int value = 0; - // bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &temp_pid); - // bundle_get_str(msg, VC_MANAGER_BUNDLE_VALUE, &temp_value); + // bundle_get_str(msg, VC_BUNDLE_PID, &temp_pid); + // bundle_get_str(msg, VC_BUNDLE_VALUE, &temp_value); // pid = atoi(temp_pid); // value = atoi(temp_value); @@ -308,7 +308,7 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ SLOG(LOG_DEBUG, TAG_VCM, "__send_buffer_cb is invoked"); - bundle_get_str(msg, VC_MANAGER_BUNDLE_METHOD, &method); + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_STREAMING, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_STREAMING))) { char *utt_id = NULL; @@ -316,9 +316,9 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ char* buffer = NULL; int len = 0; - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); - bundle_get_str(msg, VC_MANAGER_BUNDLE_UTTID, &utt_id); - bundle_get_str(msg, VC_MANAGER_BUNDLE_EVENT, &event); + bundle_get_str(msg, VC_BUNDLE_PID, &val); + bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id); + bundle_get_str(msg, VC_BUNDLE_EVENT, &event); rpc_port_proxy_vc_mgr_proxy_array_char_get(data_in, &buffer, &len); __vc_mgr_cb_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len); diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index 6f687c3..42c8017 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -35,8 +35,6 @@ typedef struct { static GList* g_tidl_infos = NULL; -extern int __vc_cb_service_state(int state); - static vc_setting_tidl_info_s* __get_tidl_info_s(int pid) { @@ -169,15 +167,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) { + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] HELLO received"); } /* VCD_METHOD_HELLO */ - else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) { - /* signal!!! */ - char* state = NULL; - bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state); - if (state) { - __vc_cb_service_state(atoi(state)); - } - } /* VCD_METHOD_SET_SERVICE_STATE */ else { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg"); } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index dbfed0d..04698a7 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -231,8 +231,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) char* utt_status = NULL; bundle_get_str(msg, VC_BUNDLE_PID, &pid); - bundle_get_str(msg, VC_BUNDLE_UTTID, &utt_id); - bundle_get_str(msg, VC_BUNDLE_UTTSTATUS, &utt_status); + bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id); + bundle_get_str(msg, VC_BUNDLE_UTT_STATUS, &utt_status); SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get utterance status : pid(%d), utt_id(%d), utt_status(%d)", atoi(pid), atoi(utt_id), atoi(utt_status)); __vc_cb_utterance_status(atoi(utt_id), atoi(utt_status)); diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index dc2b84b..091a57c 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -61,11 +61,11 @@ static void __notify_cb(void *user_data, bundle *msg) char* val = NULL; SLOG(LOG_DEBUG, TAG_VCW, "__notify_cb is invoked"); - bundle_get_str(msg, VC_WIDGET_BUNDLE_METHOD, &method); + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_WIDGET_METHOD_HELLO, method, strlen(VCD_WIDGET_METHOD_HELLO))) { SLOG(LOG_INFO, TAG_VCW, "@@@ Get widget hello"); - bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_PID, &val); if (val) { SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get hello : pid(%d) ", atoi(val)); } else { @@ -75,7 +75,7 @@ static void __notify_cb(void *user_data, bundle *msg) } /* VCD_METHOD_HELLO */ else if (0 == strncmp(VCD_WIDGET_METHOD_SET_SERVICE_STATE, method, strlen(VCD_WIDGET_METHOD_SET_SERVICE_STATE))) { - bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val); int state = 0; if (val) { state = atoi(val); @@ -87,8 +87,8 @@ static void __notify_cb(void *user_data, bundle *msg) else if (0 == strncmp(VCD_WIDGET_METHOD_SHOW_TOOLTIP, method, strlen(VCD_WIDGET_METHOD_SHOW_TOOLTIP))) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Show / Hide tooltip"); char* temp_show = NULL; - bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val); - bundle_get_str(msg, VC_WIDGET_BUNDLE_SHOW, &temp_show); + bundle_get_str(msg, VC_BUNDLE_PID, &val); + bundle_get_str(msg, VC_BUNDLE_SHOW, &temp_show); int pid = 0; int show = 0; @@ -122,9 +122,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* temp_daemon_pid = NULL; char* err_msg = NULL; - bundle_get_str(msg, VC_WIDGET_BUNDLE_REASON, &temp_reason); - bundle_get_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, &temp_daemon_pid); - bundle_get_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, &err_msg); + bundle_get_str(msg, VC_BUNDLE_REASON, &temp_reason); + bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &temp_daemon_pid); + bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg); int reason = 0; int daemon_pid = 0; diff --git a/common/vc_defs.h b/common/vc_defs.h index 2a74a03..d217052 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -68,10 +68,26 @@ extern "C" { #define VC_BUNDLE_DAEMON_PID "daemon_pid" #define VC_BUNDLE_ERR_MSG "err_msg" #define VC_BUNDLE_PID "pid" -#define VC_BUNDLE_UTTID "uttid" -#define VC_BUNDLE_UTTSTATUS "uttstatus" +#define VC_BUNDLE_UTT_ID "utt_id" +#define VC_BUNDLE_UTT_STATUS "utt_status" +#define VC_BUNDLE_UTT_TEXT "utt_text" #define VC_BUNDLE_FEEDBACK_EVENT "feedback_event" #define VC_BUNDLE_LENGTH "length" +#define VC_BUNDLE_SHOW "show" +#define VC_BUNDLE_EVENT "event" +#define VC_BUNDLE_PRE_RESULT "pre_result" +#define VC_BUNDLE_RESULT "result" +#define VC_BUNDLE_ENGINE_APP_ID "engine_app_id" +#define VC_BUNDLE_DISP_TEXT "disp_text" +#define VC_BUNDLE_CONTINUOUS "continuous" +#define VC_BUNDLE_KEY "key" +#define VC_BUNDLE_PRIVATE_DATA "private_data" +#define VC_BUNDLE_AUDIO_CHANNEL "audio_channel" +#define VC_BUNDLE_AUDIO_TYPE "audio_type" +#define VC_BUNDLE_AUDIO_RATE "audio_rate" +#define VC_BUNDLE_BUFFER "buffer" +#define VC_BUNDLE_VOLUME "volume" + /****************************************************************************************** * Message Definition for all @@ -145,14 +161,6 @@ extern "C" { #define VCD_WIDGET_METHOD_SHOW_TOOLTIP "vcd_widget_method_show_tooltip" #define VCD_WIDGET_METHOD_SET_SERVICE_STATE "vcd_widget_method_set_service_state" -#define VC_WIDGET_BUNDLE_METHOD "vc_widget_bundle_method" -#define VC_WIDGET_BUNDLE_MESSAGE "vc_widget_bundle_message" -#define VC_WIDGET_BUNDLE_SERVICE_STATE "vc_widget_bundle_service_state" -#define VC_WIDGET_BUNDLE_DAEMON_PID "vc_widget_bundle_daemon_pid" -#define VC_WIDGET_BUNDLE_SHOW "vc_widget_bundle_show" -#define VC_WIDGET_BUNDLE_REASON "vc_widget_bundle_reason" -#define VC_WIDGET_BUNDLE_ERROR_MESSAGE "vc_widget_bundle_error_message" - /****************************************************************************************** * Message Definitions for manager @@ -188,26 +196,6 @@ extern "C" { #define VC_MANAGER_METHOD_SEND_AUDIO_STREAMING "vc_manager_method_send_audio_streaming" #define VC_MANAGER_METHOD_CHANGE_SYSTEM_VOLUME "vc_manager_method_change_system_volume" -#define VC_MANAGER_BUNDLE_METHOD "vc_manager_bundle_method" -#define VC_MANAGER_BUNDLE_MESSAGE "vc_manager_bundle_message" -#define VC_MANAGER_BUNDLE_EVENT "vc_manager_bundle_event" -#define VC_MANAGER_BUNDLE_PRE_RESULT "vc_manager_bundle_pre_result" -#define VC_MANAGER_BUNDLE_ENGINE_APP_ID "vc_manager_bundle_engine_app_id" -#define VC_MANAGER_BUNDLE_RESULT "vc_manager_bundle_result" -#define VC_MANAGER_BUNDLE_DISP_TEXT "vc_manager_bundle_disp_text" -#define VC_MANAGER_BUNDLE_UTT_TEXT "vc_manager_bundle_utt_text" -#define VC_MANAGER_BUNDLE_CONTINUOUS "vc_manager_bundle_continuous" -#define VC_MANAGER_BUNDLE_REASON "vc_manager_bundle_reason" -#define VC_MANAGER_BUNDLE_DAEMON_PID "vc_manager_bundle_daemon_pid" -#define VC_MANAGER_BUNDLE_ERROR_MESSAGE "vc_manager_bundle_error_message" -#define VC_MANAGER_BUNDLE_KEY "vc_manager_bundle_key" -#define VC_MANAGER_BUNDLE_PRIVATE_DATA "vc_manager_bundle_private_data" -#define VC_MANAGER_BUNDLE_AUDIO_CHANNEL "vc_manager_bundle_audio_channel" -#define VC_MANAGER_BUNDLE_AUDIO_TYPE "vc_manager_bundle_audio_type" -#define VC_MANAGER_BUNDLE_AUDIO_RATE "vc_manager_bundle_audio_rate" -#define VC_MANAGER_BUNDLE_UTTID "vc_manager_bundle_uttid" -#define VC_MANAGER_BUNDLE_BUFFER "vc_manager_bundle_buffer" - #define VCD_MANAGER_METHOD_HELLO "vcd_manager_method_hello" #define VCD_MANAGER_METHOD_SPEECH_DETECTED "vcd_manager_method_speech_detected" #define VCD_MANAGER_METHOD_ALL_RESULT "vcd_manager_method_all_result" diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index f64dc51..237488f 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -211,103 +211,107 @@ void __send_msg(bundle* msg, vcd_client_type_e type, int pid) } } -void __send_signal(bundle* msg) +void __send_signal(bundle* msg, vcd_client_type_e type) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] send signal start"); - pthread_mutex_lock(&g_mgr_tidl_info_mutex); + if (VCD_CLIENT_TYPE_MANAGER == type) { + pthread_mutex_lock(&g_mgr_tidl_info_mutex); - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } - rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } - if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - - pthread_mutex_lock(&g_client_tidl_info_mutex); - // get all pids - int* client_list = NULL; - int client_count = 0; - int ret = -1; - ret = vcd_client_get_tidl_list(&client_list, &client_count); - - client_tidl_info_s* client_tidl_info = NULL; - int pid = -1; - - if (0 == ret && 0 < client_count) { - for (int i = 0 ; i < client_count ; i++) { - pid = client_list[i]; - - client_tidl_info = vcd_client_get_tidl_info(pid); - if (NULL == client_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); - continue; - } - - if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(client_tidl_info->notify_cb, pid, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - continue; + } /* signal to MANAGER */ + else if (VCD_CLIENT_TYPE_NORMAL == type) { + pthread_mutex_lock(&g_client_tidl_info_mutex); + // get all pids + int* client_list = NULL; + int client_count = 0; + int ret = -1; + ret = vcd_client_get_tidl_list(&client_list, &client_count); + + client_tidl_info_s* client_tidl_info = NULL; + int pid = -1; + + if (0 == ret && 0 < client_count) { + for (int i = 0 ; i < client_count ; i++) { + pid = client_list[i]; + + client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); + continue; + } + + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(client_tidl_info->notify_cb, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + continue; + } } } - } - pthread_mutex_unlock(&g_client_tidl_info_mutex); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + } /* signal to clients */ + else if (VCD_CLIENT_TYPE_WIDGET == type) { + pthread_mutex_lock(&g_widget_tidl_info_mutex); + GSList *iter = NULL; + GSList* widget_list = vcd_client_widget_get_tidl_info_list(); - pthread_mutex_lock(&g_widget_tidl_info_mutex); - GSList *iter = NULL; - GSList* widget_list = vcd_client_widget_get_tidl_info_list(); + int count = g_slist_length(widget_list); + int i; - int count = g_slist_length(widget_list); - int i; + widget_tidl_info_s *widget_tidl_info = NULL; - widget_tidl_info_s *widget_tidl_info = NULL; + if (0 < count) { + iter = g_slist_nth(widget_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list iterator broken"); + break; + } - if (0 < count) { - iter = g_slist_nth(widget_list, 0); - for (i = 0; i < count; i++) { - if (NULL == iter) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list iterator broken"); - break; - } + widget_tidl_info = iter->data; - widget_tidl_info = iter->data; + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list data broken"); + break; + } - if (NULL == widget_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list data broken"); - break; - } + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to widget"); - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to widget"); + rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + break; + } - rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - break; - } + if (0 != rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_invoke(handle, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + break; + } - if (0 != rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_invoke(handle, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - break; + iter = g_slist_next(iter); } - - iter = g_slist_next(iter); } - } - pthread_mutex_unlock(&g_widget_tidl_info_mutex); + pthread_mutex_unlock(&g_widget_tidl_info_mutex); + } /* signal to widgets */ } @@ -2047,11 +2051,11 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_HELLO); bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); } else if (VCD_CLIENT_TYPE_MANAGER == type) { - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_HELLO); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_HELLO); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); } else if (VCD_CLIENT_TYPE_WIDGET == type) { - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_HELLO); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_HELLO); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); } else { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); bundle_free(msg); @@ -2130,8 +2134,8 @@ int vcdc_send_set_volume(int manager_pid, float volume) bundle* msg = bundle_create(); snprintf(tmp_volume, 20, "%.6f", volume); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_VOLUME); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_volume); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_VOLUME); + bundle_add_str(msg, VC_BUNDLE_VOLUME, tmp_volume); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2159,9 +2163,9 @@ int vcdc_send_show_tooltip(int pid, bool show) snprintf(tmp_pid, 10, "%d", pid); snprintf(tmp_show, 10, "%d", (int)show); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SHOW_TOOLTIP); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_WIDGET_BUNDLE_SHOW, tmp_show); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_SHOW_TOOLTIP); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_SHOW, tmp_show); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2232,9 +2236,9 @@ int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_ bundle* msg = bundle_create(); snprintf(tmp_event, 10, "%d", event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_PRE_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_PRE_RESULT, pre_result); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_PRE_RESULT); + bundle_add_str(msg, VC_BUNDLE_EVENT, tmp_event); + bundle_add_str(msg, VC_BUNDLE_PRE_RESULT, pre_result); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2252,10 +2256,10 @@ int vcdc_send_specific_engine_result_to_manager(int manager_pid, const char* eng gchar *gEncodedResult = g_base64_encode((const guchar*)result, strlen(result)); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ENGINE_APP_ID, engine_app_id); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_RESULT, gEncodedResult); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT); + bundle_add_str(msg, VC_BUNDLE_ENGINE_APP_ID, engine_app_id); + bundle_add_str(msg, VC_BUNDLE_EVENT, event); + bundle_add_str(msg, VC_BUNDLE_RESULT, gEncodedResult); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2277,8 +2281,8 @@ int vcdc_send_result_to_manager(int manager_pid, int result_type) bundle* msg = bundle_create(); snprintf(tmp_result, 10, "%d", result_type); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ALL_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_result); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_ALL_RESULT); + bundle_add_str(msg, VC_BUNDLE_RESULT, tmp_result); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2295,7 +2299,7 @@ int vcdc_send_speech_detected(int manager_pid) bundle* msg = bundle_create(); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPEECH_DETECTED); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPEECH_DETECTED); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2314,17 +2318,19 @@ int vcdc_send_service_state(vcd_state_e state) bundle* msg = bundle_create(); snprintf(tmp_state, 10, "%d", (int)state); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_SERVICE_STATE); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_state); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); + __send_signal(msg, VCD_CLIENT_TYPE_MANAGER); bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SET_SERVICE_STATE); bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); + __send_signal(msg, VCD_CLIENT_TYPE_NORMAL); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SET_SERVICE_STATE); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_state); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); + __send_signal(msg, VCD_CLIENT_TYPE_WIDGET); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); - __send_signal(msg); bundle_free(msg); return VCD_ERROR_NONE; @@ -2354,11 +2360,11 @@ int vcdc_send_dialog(int manager_pid, int pid, const char* disp_text, const char tmp_utt_text = strdup(utt_text); } - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_DIALOG); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DISP_TEXT, tmp_disp_text); - bundle_add_str(msg, VC_MANAGER_BUNDLE_UTT_TEXT, tmp_utt_text); - bundle_add_str(msg, VC_MANAGER_BUNDLE_CONTINUOUS, tmp_continuous); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_DIALOG); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_DISP_TEXT, tmp_disp_text); + bundle_add_str(msg, VC_BUNDLE_UTT_TEXT, tmp_utt_text); + bundle_add_str(msg, VC_BUNDLE_CONTINUOUS, tmp_continuous); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2389,10 +2395,10 @@ int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg) snprintf(tmp_reason, 10, "%d", reason); snprintf(tmp_daemon_pid, 10, "%d", getpid()); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); + bundle_add_str(msg, VC_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, temp_msg); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2428,15 +2434,15 @@ int vcdc_tidl_send_error(int reason, char *err_msg) snprintf(tmp_reason, 10, "%d", reason); snprintf(tmp_daemon_pid, 10, "%d", getpid()); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); + bundle_add_str(msg, VC_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, temp_msg); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_WIDGET_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, temp_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_ERROR); + bundle_add_str(msg, VC_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, temp_msg); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); @@ -2459,10 +2465,10 @@ int vcdc_send_request_set_private_data(int pid, const char* key, const char* dat bundle* msg = bundle_create(); snprintf(tmp_pid, 10, "%d", pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_PRIVATE_DATA); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_KEY, key); - bundle_add_str(msg, VC_MANAGER_BUNDLE_PRIVATE_DATA, data); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_PRIVATE_DATA); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_KEY, key); + bundle_add_str(msg, VC_BUNDLE_PRIVATE_DATA, data); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2484,10 +2490,10 @@ int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_aud snprintf(tmp_rate, 10, "%d", rate); snprintf(tmp_channel, 10, "%d", (int)channel); snprintf(tmp_audio_type, 10, "%d", (int)audio_type); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_RATE, tmp_rate); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_CHANNEL, tmp_channel); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_TYPE, tmp_audio_type); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT); + bundle_add_str(msg, VC_BUNDLE_AUDIO_RATE, tmp_rate); + bundle_add_str(msg, VC_BUNDLE_AUDIO_CHANNEL, tmp_channel); + bundle_add_str(msg, VC_BUNDLE_AUDIO_TYPE, tmp_audio_type); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2509,10 +2515,10 @@ int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id snprintf(tmp_pid, 10, "%d", pid); snprintf(tmp_utt_id, 10, "%d", utt_id); snprintf(tmp_event, 10, "%d", (int)event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_STREAMING); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_UTTID, tmp_utt_id); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_STREAMING); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_UTT_ID, tmp_utt_id); + bundle_add_str(msg, VC_BUNDLE_EVENT, tmp_event); rpc_port_stub_vcd_mgr_stub_array_char_h streaming_data = NULL; rpc_port_stub_vcd_mgr_stub_array_char_create(&streaming_data); -- 2.7.4 From c901d727e37949af62dfbe801e5053c965563f85 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 30 Jun 2022 11:48:50 +0900 Subject: [PATCH 04/16] Remove unnecessary command and Fix return value in vcd_client_widget_get_foreground_pid() Change-Id: I686738186f46907a74adccf412bc2295a1b79655 Signed-off-by: sooyeon --- packaging/voice-control.spec | 4 ---- server/vcd_client_data.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 952b983..eff8088 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -154,10 +154,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} -%if "%{tizen_profile_name}" == "tv" -mv -f org.tizen.voice.vcserver.tv.service org.tizen.voice.vcserver.service -%endif - %make_install %if 0%{?gcov:1} diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 404d52f..057d919 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -1828,7 +1828,7 @@ int vcd_client_widget_get_foreground_pid() widget = __widget_get_element(fg_pid); if (NULL == widget) { SLOG(LOG_WARN, TAG_VCD, "[Client Data] Not found foreground pid of widget"); - return VCD_ERROR_INVALID_PARAMETER; + return -1; } return widget->pid; -- 2.7.4 From 570e4da59c2d2838ed6e1cd21fb66a90e3af04db Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 30 Jun 2022 13:37:55 +0900 Subject: [PATCH 05/16] Fix a minor issue (engine_appid was not saved in info handle) Change-Id: I380beddfa0953fd21a9524158d8aa5b8f098878c Signed-off-by: sooyeon --- client/vc_tidl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 04698a7..61ea8ea 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -355,16 +355,16 @@ int vc_tidl_open_connection() } int pid = getpid(); - char* engine_appid = __get_engine_appid(); + info->pid = pid; + info->engine_appid = __get_engine_appid(); - info->rpc_h = __create_rpc_port(pid, engine_appid); + info->rpc_h = __create_rpc_port(pid, info->engine_appid); if (NULL == info->rpc_h) { SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create proxy"); free(info); return VC_ERROR_OPERATION_FAILED; } - info->pid = pid; g_tidl_infos = g_list_append(g_tidl_infos, info); SLOG(LOG_ERROR, TAG_VCC, "[TIDL] pid(%d) rpc_h(%p), engine_appid(%s)", pid, info->rpc_h, info->engine_appid); -- 2.7.4 From 482805ea8012b14ac834ad21e0d45ce7860a6106 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 30 Jun 2022 17:44:12 +0900 Subject: [PATCH 06/16] Rename function name and Rearrange codes Change-Id: Iaa053e9004dd3aaf3e6caa99bfcab5288d73211b Signed-off-by: sooyeon --- server/vcd_engine_agent.c | 2 +- server/vcd_server.c | 14 +++++++------- server/vcd_tidl.c | 10 +++++++--- server/vcd_tidl.h | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 9c3c9c1..c000e7b 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -922,7 +922,7 @@ int vcd_engine_agent_start_recording() SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recorder : result(%d)", ret); vcd_engine_recognize_cancel(); /* Send error cb to manager */ - vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.vcfw.send_rc_fail"); + vcdc_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.vcfw.send_rc_fail"); return ret; } diff --git a/server/vcd_server.c b/server/vcd_server.c index 16717a5..f22895f 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -145,9 +145,9 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt ecore_timer_add(0, __cancel_by_interrupt, NULL); /* Send error cb to manager */ if (VCE_ERROR_OUT_OF_NETWORK == ret) { - vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_TIMED_OUT, "voice_framework.error.engine.set_recording_fail"); + vcdc_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_TIMED_OUT, "voice_framework.error.engine.set_recording_fail"); } else { - vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), ret, "voice_framework.error.engine.set_recording_fail"); + vcdc_send_error_to_manager(vcd_client_manager_get_pid(), ret, "voice_framework.error.engine.set_recording_fail"); } return VCD_ERROR_NONE; } @@ -1123,7 +1123,7 @@ int vcd_send_error(vce_error_e error, const char* msg, void *user_data) int pid = __get_tts_played_pid(); ret = vcdc_send_error_signal_to_app(pid, error, error_msg); } else { - ret = vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), error, error_msg); + ret = vcdc_send_error_to_manager(vcd_client_manager_get_pid(), error, error_msg); ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL); } @@ -1898,7 +1898,7 @@ static int __start_internal_recognition() /* Send error cb to manager */ int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) - vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.vcfw.collect_command_fail"); + vcdc_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.vcfw.collect_command_fail"); return VCD_ERROR_OPERATION_FAILED; } @@ -1909,7 +1909,7 @@ static int __start_internal_recognition() /* Send error cb to manager */ int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) - vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.engine.set_commands_fail"); + vcdc_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.engine.set_commands_fail"); return VCD_ERROR_OPERATION_FAILED; } @@ -1929,7 +1929,7 @@ static int __start_internal_recognition() /* Send error cb to manager */ int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) - vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), ret, "voice_framework.error.engine.start_fail"); + vcdc_send_error_to_manager(vcd_client_manager_get_pid(), ret, "voice_framework.error.engine.start_fail"); return ret; } @@ -1944,7 +1944,7 @@ static int __start_internal_recognition() /* Send error cb to manager */ int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) - vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.vcfw.send_rc_fail"); + vcdc_send_error_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_framework.error.vcfw.send_rc_fail"); return ret; } #endif diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 237488f..631643b 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -57,7 +57,9 @@ extern int __setting_tidl_open_connection(); extern int __setting_tidl_close_connection(); -/* For common request */ +/** + * For common request + */ static void __request_tidl_connect(vcd_client_type_e type, int pid) { char* type_str = NULL; @@ -1916,7 +1918,9 @@ int __setting_tidl_close_connection() } - +/** + * Functions for sending the information to client sides + */ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) { if (NULL == err_msg) { @@ -2376,7 +2380,7 @@ int vcdc_send_dialog(int manager_pid, int pid, const char* disp_text, const char return VCD_ERROR_NONE; } -int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg) +int vcdc_send_error_to_manager(int manager_pid, int reason, char *err_msg) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL] Send error signal to manager"); diff --git a/server/vcd_tidl.h b/server/vcd_tidl.h index 839258b..4b555f3 100644 --- a/server/vcd_tidl.h +++ b/server/vcd_tidl.h @@ -52,7 +52,7 @@ int vcdc_send_speech_detected(int manger_pid); // int vcdc_tidl_send_error(int reason, char *err_msg); -int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg); +int vcdc_send_error_to_manager(int manager_pid, int reason, char *err_msg); int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); -- 2.7.4 From 86a0d9b245830d3a4fec3557b45e1f726bbca706 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 30 Jun 2022 18:33:26 +0900 Subject: [PATCH 07/16] Add privilege checker for TIDL privileges Change-Id: Iaf23e79bf61094688579297613f7e1ec3753d618 Signed-off-by: sooyeon --- client/vc.c | 31 ++++++++++++++++++++++++++++--- client/vc_mgr.c | 23 ++++++++++++++++++++--- common/vc_command.c | 32 +++++++++++++++++++++++++++++--- common/vc_defs.h | 6 ++++-- server/vce.c | 34 +++++++++++++++++++++++++++++++--- 5 files changed, 112 insertions(+), 14 deletions(-) diff --git a/client/vc.c b/client/vc.c index 4fed631..fecde6a 100644 --- a/client/vc.c +++ b/client/vc.c @@ -167,15 +167,40 @@ static int __vc_check_privilege() char uid[32]; snprintf(uid, 32, "%d", getuid()); ret = true; - ret = __check_privilege(uid, VC_PRIVILEGE); - __check_privilege_deinitialize(); + ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); if (false == ret) { //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied"); + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_STOP } + + ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + + ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + + __check_privilege_deinitialize(); } g_privilege_allowed = true; diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 5019344..4fe673d 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -229,16 +229,15 @@ static int __vc_mgr_check_privilege() char uid[32]; snprintf(uid, 32, "%d", getuid()); ret = true; - ret = __check_privilege(uid, VC_PRIVILEGE); + ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); if (false == ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE, uid); + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid); __check_privilege_deinitialize(); g_privilege_allowed = false; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; } - ret = true; ret = __check_privilege(uid, VC_MGR_PRIVILEGE); if (false == ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_MGR_PRIVILEGE, uid); @@ -248,6 +247,24 @@ static int __vc_mgr_check_privilege() return VC_ERROR_PERMISSION_DENIED; } + ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); + if (false == ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + } + + ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); + if (false == ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + } + __check_privilege_deinitialize(); } diff --git a/common/vc_command.c b/common/vc_command.c index 3f1b32b..34138f3 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -160,14 +160,40 @@ static int __vc_cmd_check_privilege() char uid[32]; snprintf(uid, 32, "%d", getuid()); ret = true; - ret = __check_privilege(uid, VC_PRIVILEGE); - __check_privilege_deinitialize(); + ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + + ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); if (false == ret) { - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied"); + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); + __check_privilege_deinitialize(); g_privilege_allowed = false; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } + + ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + + __check_privilege_deinitialize(); } g_privilege_allowed = true; diff --git a/common/vc_defs.h b/common/vc_defs.h index d217052..d9a07b5 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -276,8 +276,10 @@ extern "C" { #define VC_MGR_FEATURE_PATH "tizen.org/feature/speech.control_manager" #define VC_MIC_FEATURE_PATH "tizen.org/feature/microphone" -#define VC_PRIVILEGE "http://tizen.org/privilege/recorder" -#define VC_MGR_PRIVILEGE "http://tizen.org/privilege/voicecontrol.manager" +#define VC_PRIVILEGE_RECORDER "http://tizen.org/privilege/recorder" +#define VC_MGR_PRIVILEGE "http://tizen.org/privilege/voicecontrol.manager" +#define VC_PRIVILEGE_DATASHARING "http://tizen.org/privilege/datasharing" +#define VC_PRIVILEGE_APPMGR "http://tizen.org/privilege/appmanager.launch" /****************************************************************************************** * Definitions for common enum diff --git a/server/vce.c b/server/vce.c index be70147..7ea2327 100644 --- a/server/vce.c +++ b/server/vce.c @@ -130,13 +130,41 @@ static int __vce_check_privilege() char uid[32]; snprintf(uid, 32, "%d", getuid()); ret = true; - ret = __check_privilege(uid, VC_PRIVILEGE); - __check_privilege_deinitialize(); + ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VCE_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + + ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VCE_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + + ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); if (false == ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied"); + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; pthread_mutex_unlock(&g_cynara_mutex); return VCE_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } + + __check_privilege_deinitialize(); + } g_privilege_allowed = true; -- 2.7.4 From c8aed00af31d6d8afb78e621084101b758637ba6 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 4 Jul 2022 16:55:59 +0900 Subject: [PATCH 08/16] Fix TC issues (ignore ipc error in vce TCs and remove unnecessary codes) Change-Id: I4944efd2ce825fc69ab6dcc86d90bc2b854f8d35 Signed-off-by: sooyeon --- server/vcd_server.c | 2 +- server/vcd_tidl.c | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/server/vcd_server.c b/server/vcd_server.c index f22895f..3939f9c 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1173,7 +1173,7 @@ int vcd_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int le SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback streaming event(%d), uid(%u), is_mgr_client(%d)", event, g_current_tts_uid, (pid == vcd_client_manager_get_pid() ? true : false)); - if (pid == vcd_client_manager_get_pid()) { + if (VC_INVALID_TTS_UID == pid || pid == vcd_client_manager_get_pid() || -1 == vcd_client_manager_get_pid()) { /* send TTS feedback streaming to manager client */ ret = vcdc_send_feedback_streaming_to_manager(vcd_client_manager_get_pid(), pid, utt_id, event, buffer, len); if (VCD_ERROR_NONE != ret) { diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 631643b..b7709f3 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -594,7 +594,7 @@ static int __vc_request_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context, i SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d), ret(%d)", pid, disp_text, utt_text, continuous, ret); } - return ret; + return VCD_ERROR_NONE; } static int __vc_is_system_command_valid_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data) @@ -2018,13 +2018,7 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, client_tidl_info_s* info = vcd_client_get_tidl_info(pid); if (NULL == info) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); - return VCD_ERROR_INVALID_PARAMETER; - } - - bundle* msg = bundle_create(); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); - return VCD_ERROR_OUT_OF_MEMORY; + return VCD_ERROR_NONE; } SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len); @@ -2037,7 +2031,6 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, rpc_port_stub_vcd_stub_array_char_destroy(arr_char); - bundle_free(msg); return VCD_ERROR_NONE; } @@ -2548,7 +2541,7 @@ int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id pthread_mutex_unlock(&g_mgr_tidl_info_mutex); rpc_port_stub_vcd_mgr_stub_array_char_destroy(streaming_data); bundle_free(msg); - return VCD_ERROR_OPERATION_FAILED; + return VCD_ERROR_NONE; } rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h handle = mgr_tidl_info->send_buffer_cb; -- 2.7.4 From 3c819a707659fab46631a4f1780fb593b9c2cc2c Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 6 Jul 2022 13:56:28 +0900 Subject: [PATCH 09/16] Replace duplicated codes and Remove unnecessary logs Change-Id: I595a15ba1e9b430e6e6f31ab84a491d60f7fc175 Signed-off-by: sooyeon --- client/vc.c | 575 +++++++++++++---------------------------------- client/vc_mgr.c | 556 +++++++++------------------------------------ client/vc_setting_tidl.c | 14 +- client/vc_tidl.c | 74 +++--- client/vc_widget.c | 294 ++++++------------------ common/vc_main.h | 11 +- server/vcd_tidl.c | 76 +++---- 7 files changed, 411 insertions(+), 1189 deletions(-) diff --git a/client/vc.c b/client/vc.c index fecde6a..1b6d87a 100644 --- a/client/vc.c +++ b/client/vc.c @@ -397,7 +397,6 @@ int vc_initialize(void) SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_vc->handle); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_NONE; } @@ -690,15 +689,10 @@ int vc_prepare(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'CREATED'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); ecore_thread_run(__start_prepare_thread, __end_prepare_thread, NULL, NULL); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_NONE; } @@ -723,23 +717,14 @@ int vc_prepare_sync(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'INITIALIZED'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); int cnt = 0; while (EINA_TRUE == __vc_connect_daemon(NULL) && VC_CONNECTION_RETRY_COUNT > cnt) { cnt++; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - if (VC_CONNECTION_RETRY_COUNT == cnt) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to connect daemon"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_CONNECTION_RETRY_COUNT == cnt, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Fail to connect daemon"); return VC_ERROR_NONE; } @@ -759,23 +744,18 @@ int vc_unprepare(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); __vc_internal_unprepare(); vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unprepare DONE"); return VC_ERROR_NONE; } @@ -789,13 +769,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language"); - - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -804,6 +778,9 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user return VC_ERROR_INVALID_STATE; } + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language"); + + int ret = -1; ret = vc_config_mgr_get_language_list(callback, user_data); if (0 != ret) { @@ -811,7 +788,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get languages : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language DONE"); return VC_ERROR_NONE; } @@ -826,13 +803,7 @@ int vc_get_current_language(char** language) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); - - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -841,6 +812,9 @@ int vc_get_current_language(char** language) return VC_ERROR_INVALID_STATE; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); + int ret = -1; ret = vc_config_mgr_get_default_language(language); if (0 != ret) { @@ -848,7 +822,7 @@ int vc_get_current_language(char** language) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current languages : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language DONE"); return ret; } @@ -862,12 +836,7 @@ int vc_get_state(vc_state_e* state) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get State"); - - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (0 != vc_client_get_client_state(g_vc, &temp)) { @@ -876,6 +845,9 @@ int vc_get_state(vc_state_e* state) return VC_ERROR_INVALID_STATE; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get State"); + *state = temp; switch (*state) { @@ -887,7 +859,7 @@ int vc_get_state(vc_state_e* state) //LCOV_EXCL_STOP } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get State DONE"); return VC_ERROR_NONE; } @@ -901,25 +873,15 @@ int vc_get_service_state(vc_service_state_e* state) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State"); - - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (0 != vc_client_get_client_state(g_vc, &temp)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } - if (VC_STATE_READY != temp) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != temp, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", temp); /* get service state */ vc_service_state_e service_state; @@ -928,6 +890,9 @@ int vc_get_service_state(vc_service_state_e* state) return VC_ERROR_OPERATION_FAILED; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State"); + *state = service_state; switch (*state) { @@ -940,7 +905,7 @@ int vc_get_service_state(vc_service_state_e* state) //LCOV_EXCL_STOP } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State DONE"); return VC_ERROR_NONE; } @@ -954,36 +919,25 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get system command list"); - - if (NULL == vc_sys_cmd_list) { - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_sys_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); *vc_sys_cmd_list = NULL; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get system command list"); bool is_sys_cmd_valid = false; int count = 0; @@ -1050,7 +1004,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) return VC_ERROR_NONE; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get system command list DONE"); return ret; } @@ -1106,7 +1060,7 @@ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) SLOG(LOG_ERROR, TAG_VCC, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Is command format supported DONE"); return VC_ERROR_NONE; } @@ -1171,6 +1125,40 @@ static int __vc_get_invocation_name(char** invocation_name) return VC_ERROR_NONE; } +void __set_command(vc_h vc, vc_cmd_type_e type) +{ + int ret = -1; + int count = 0; + bool is_prepared = false; + do { + ret = vc_tidl_request_set_command(vc->handle, type); + if (0 != ret) { + //LCOV_EXCL_START + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); + break; + } else { + SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set command : %s", __vc_get_error_code(ret)); + usleep(10000); + count++; + if (VC_RETRY_COUNT == count) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); + break; + } + } + //LCOV_EXCL_STOP + } + } while (0 != ret); + + return; +} + int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) { if (0 != __vc_get_feature_enabled()) { @@ -1180,12 +1168,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list"); - - if (NULL == vc_cmd_list) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1195,26 +1178,20 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list"); /* check type */ if ((VC_COMMAND_TYPE_FOREGROUND != type) && (VC_COMMAND_TYPE_BACKGROUND != type)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command type: input type is %d", type); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_PARAMETER; } vc_cmd_list_s* list = NULL; list = (vc_cmd_list_s*)vc_cmd_list; - - if (NULL == list->list) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command list"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Invalid command list"); int ret = 0; char* invocation_name = NULL; @@ -1234,33 +1211,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save command list : %s", __vc_get_error_code(ret)); } else { - int count = 0; - bool is_prepared = false; - do { - ret = vc_tidl_request_set_command(g_vc->handle, (vc_cmd_type_e)type); - if (0 != ret) { - //LCOV_EXCL_START - if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); - if (0 == vc_prepare_sync()) { - is_prepared = true; - SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); - } - } else if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set command : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - //LCOV_EXCL_STOP - } - } while (0 != ret); + __set_command(g_vc, (vc_cmd_type_e)type); } FREE(invocation_name); @@ -1268,7 +1219,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) if (VC_COMMAND_TYPE_BACKGROUND == type) g_backup = true; - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list DONE"); return ret; } @@ -1282,21 +1233,17 @@ int vc_unset_command_list(int type) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list"); - vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list"); int count = 0; int ret = -1; @@ -1333,7 +1280,7 @@ int vc_unset_command_list(int type) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] cmd_type(%d), Fail to delete command list : %s", type, __vc_get_error_code(ret)); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list DONE"); return ret; } @@ -1348,8 +1295,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file"); - vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); @@ -1358,11 +1303,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* check type */ if ((VC_COMMAND_TYPE_FOREGROUND != type) && (VC_COMMAND_TYPE_BACKGROUND != type)) { @@ -1371,6 +1312,9 @@ int vc_set_command_list_from_file(const char* file_path, int type) return VC_ERROR_INVALID_PARAMETER; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file"); + int ret = 0; char* invocation_name = NULL; if (VC_COMMAND_TYPE_BACKGROUND == type) { @@ -1389,36 +1333,12 @@ int vc_set_command_list_from_file(const char* file_path, int type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set commands from file : %s", __vc_get_error_code(ret)); } else { - int count = 0; - bool is_prepared = false; - do { - ret = vc_tidl_request_set_command(g_vc->handle, (vc_cmd_type_e)type); - if (0 != ret) { - if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); - if (0 == vc_prepare_sync()) { - is_prepared = true; - SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); - } - } else if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set command : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - } - } while (0 != ret); + __set_command(g_vc, (vc_cmd_type_e)type); } FREE(invocation_name); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file DONE"); return ret; } //LCOV_EXCL_STOP @@ -1792,10 +1712,7 @@ static Eina_Bool __vc_notify_result(void *data) vc_client_get_result_cb(g_vc, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Client result callback is NULL"); - return EINA_FALSE; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCC, "[ERROR] Client result callback is NULL"); if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create command list"); @@ -1840,8 +1757,6 @@ int vc_get_result(vc_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result"); - vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); @@ -1850,16 +1765,12 @@ int vc_get_result(vc_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); + + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Client result callback is NULL"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_PARAMETER; - } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result"); char* temp_text = NULL; int event = 0; @@ -1890,7 +1801,7 @@ int vc_get_result(vc_result_cb callback, void* user_data) /* Release result */ FREE(temp_text); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result DONE"); return VC_ERROR_NONE; } @@ -1904,8 +1815,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1914,10 +1824,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_result_cb(g_vc, callback, user_data); @@ -1940,10 +1847,7 @@ int vc_unset_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_result_cb(g_vc, NULL, NULL); @@ -2003,8 +1907,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client service state changed callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2013,10 +1916,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_service_state_changed_cb(g_vc, callback, user_data); @@ -2039,10 +1939,7 @@ int vc_unset_service_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_service_state_changed_cb(g_vc, NULL, NULL); @@ -2058,8 +1955,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (callback == NULL) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client state changed callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2068,10 +1964,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_state_changed_cb(g_vc, callback, user_data); @@ -2094,10 +1987,7 @@ int vc_unset_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_state_changed_cb(g_vc, NULL, NULL); @@ -2113,8 +2003,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client current language changed callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2123,10 +2012,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_current_lang_changed_cb(g_vc, callback, user_data); @@ -2149,10 +2035,7 @@ int vc_unset_current_language_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_current_lang_changed_cb(g_vc, NULL, NULL); @@ -2168,8 +2051,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client error callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2178,10 +2060,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_error_cb(g_vc, callback, user_data); @@ -2204,10 +2083,7 @@ int vc_unset_error_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_error_cb(g_vc, NULL, NULL); @@ -2234,11 +2110,7 @@ int vc_set_invocation_name(const char* name) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); ret = vc_client_set_invocation_name(g_vc, name); if (0 != ret) { @@ -2253,7 +2125,6 @@ int vc_set_server_dialog(const char* app_id, const char* credential) vc_state_e state; int ret = -1; - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog, pid(%d), app_id(%s)", getpid(), app_id); if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } @@ -2261,32 +2132,23 @@ int vc_set_server_dialog(const char* app_id, const char* credential) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == credential) { - SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Credential is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == credential, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Credential is NULL"); if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog, pid(%d), app_id(%s)", getpid(), app_id); char* tmp_appid = NULL; if (NULL == app_id) { @@ -2331,7 +2193,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) FREE(tmp_appid); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog DONE"); return ret; } @@ -2340,8 +2202,8 @@ int vc_unset_server_dialog(const char* app_id) { vc_state_e state; int ret = -1; + char* tmp_appid = NULL; - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog, pid(%d), app_id(%s)", getpid(), app_id); if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } @@ -2351,27 +2213,18 @@ int vc_unset_server_dialog(const char* app_id) if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); + - char* tmp_appid = NULL; if (NULL == app_id) { ret = app_manager_get_app_id(getpid(), &tmp_appid); if (0 != ret || NULL == tmp_appid) { @@ -2384,7 +2237,7 @@ int vc_unset_server_dialog(const char* app_id) } int pid = getpid(); - SLOG(LOG_DEBUG, TAG_VCC, "Unset server dialog : pid(%d), app_id(%s)", pid, tmp_appid); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog : pid(%d), app_id(%s)", pid, tmp_appid); int count = 0; bool is_prepared = false; @@ -2416,7 +2269,7 @@ int vc_unset_server_dialog(const char* app_id) FREE(tmp_appid); FREE(credential); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog DONE"); return ret; } @@ -2426,7 +2279,6 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta { vc_state_e state; - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog"); if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } @@ -2436,34 +2288,25 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start); int ret = vc_tidl_request_request_dialog(getpid(), disp_text, utt_text, auto_start); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request dialog, ret(%d)", ret); return VC_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog DONE"); return VC_ERROR_NONE; } @@ -2478,11 +2321,7 @@ int vc_auth_enable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Current state(%d) is not 'READY'", state); /* check already authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2490,11 +2329,7 @@ int vc_auth_enable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Already authority enabled"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE != auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Already authority enabled"); /* request authority */ int mgr_pid = -1; @@ -2541,11 +2376,7 @@ int vc_auth_disable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Current state(%d) is not 'READY'", state); /* check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2553,11 +2384,7 @@ int vc_auth_disable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE == auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] No authority"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] No authority"); if (0 != vc_auth_unset_state_changed_cb()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to unset state changed cb"); @@ -2596,11 +2423,7 @@ int vc_auth_get_state(vc_auth_state_e* state) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_STATE_READY != vc_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != vc_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Current state(%d) is not 'READY'", vc_state); /* get authority */ vc_auth_state_e temp = VC_AUTH_STATE_NONE; @@ -2630,11 +2453,7 @@ int vc_auth_set_state_changed_cb(vc_auth_state_changed_cb callback, void* user_d SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE == auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Auth is not enabled"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Auth is not enabled"); /* set cb into handle */ if (0 != vc_client_set_auth_state_changed_cb(g_vc, callback, user_data)) { @@ -2655,11 +2474,7 @@ int vc_auth_unset_state_changed_cb(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE == auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Auto is not enabled"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Auth is not enabled"); /* unset cb from handle */ if (0 != vc_client_unset_auth_state_changed_cb(g_vc)) { @@ -2684,20 +2499,12 @@ int vc_auth_start(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: client state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); /* Check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2705,11 +2512,7 @@ int vc_auth_start(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } - - if (VC_AUTH_STATE_VALID != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not auth valid"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_AUTH_STATE_VALID != auth_state, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not auth valid"); /* get mgr_pid */ int mgr_pid = -1; @@ -2765,20 +2568,12 @@ int vc_auth_stop(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: client state is not 'Ready'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_RECORDING) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'RECORDING'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_RECORDING, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'RECORDING'", service_state); /* Check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2786,11 +2581,7 @@ int vc_auth_stop(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } - - if (VC_AUTH_STATE_VALID != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not auth valid"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_AUTH_STATE_VALID != auth_state, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not auth valid"); /* get mgr_pid */ int mgr_pid = -1; @@ -2846,11 +2637,7 @@ int vc_auth_cancel(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'Ready'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; @@ -2867,11 +2654,7 @@ int vc_auth_cancel(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } - - if (VC_AUTH_STATE_VALID != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not auth valid"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_AUTH_STATE_VALID != auth_state, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not auth valid"); /* get mgr_pid */ int mgr_pid = -1; @@ -2922,10 +2705,7 @@ static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) void* user_data = NULL; vc_client_get_tts_streaming_cb(g_vc, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] tts streaming callback is null"); - return; - } + RETM_IF(NULL == callback, TAG_VCC, "[WARNING] tts streaming callback is null"); while (1) { int ret = -1; @@ -2987,10 +2767,7 @@ int __vc_cb_tts_streaming(int utt_id, vc_tts_event_e event, char* buffer, int le /* add tts data */ vc_tts_data_s* temp_tts_data = NULL; temp_tts_data = (vc_tts_data_s*)calloc(1, sizeof(vc_tts_data_s)); - if (NULL == temp_tts_data) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Out of memory"); - return VC_ERROR_OUT_OF_MEMORY; - } + RETVM_IF(NULL == temp_tts_data, VC_ERROR_OUT_OF_MEMORY, TAG_VCC, "[ERROR] Out of memory"); temp_tts_data->data = NULL; temp_tts_data->data_size = 0; @@ -3050,20 +2827,12 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ tts request, pid(%d), text(%s), language(%s), to_vc_manager(%d)", pid, text, language, to_vc_manager); @@ -3120,20 +2889,12 @@ int vc_tts_cancel(int utt_id) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ tts cancel, pid(%d), utt_id(%d)", pid, utt_id); @@ -3195,20 +2956,12 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ get tts audio format, pid(%d)", pid); @@ -3262,10 +3015,7 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set tts streaming callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_streaming_cb(g_vc, callback, user_data); @@ -3288,10 +3038,7 @@ int vc_tts_unset_streaming_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset tts streaming callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_streaming_cb(g_vc, NULL, NULL); @@ -3304,10 +3051,7 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) void* user_data = NULL; vc_client_get_tts_utterance_status_cb(g_vc, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] Utterance status callback is null"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); SLOG(LOG_DEBUG, TAG_VCC, "Utterance status callback is called"); vc_client_use_callback(g_vc); @@ -3326,8 +3070,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3336,10 +3079,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set tts utterance status callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_utterance_status_cb(g_vc, callback, user_data); @@ -3362,10 +3102,7 @@ int vc_tts_unset_utterance_status_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset tts utterance status callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_utterance_status_cb(g_vc, NULL, NULL); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 4fe673d..061f0be 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -583,11 +583,7 @@ int vc_mgr_prepare(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'CREATED'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); if (NULL == g_send_hello_timer) { g_tidl_send_hello_count = 0; @@ -625,11 +621,7 @@ int vc_mgr_unprepare(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); __vc_mgr_internal_unprepare(); @@ -654,11 +646,7 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -690,10 +678,7 @@ int vc_mgr_get_current_language(char** language) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -726,10 +711,7 @@ int vc_mgr_get_state(vc_state_e* state) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (NULL == g_vc_m) { @@ -767,10 +749,7 @@ int vc_mgr_get_service_state(vc_service_state_e* state) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e client_state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &client_state)) { @@ -827,11 +806,7 @@ int vc_mgr_set_demandable_client_rule(const char* rule) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); int ret = -1; ret = vc_info_parser_set_demandable_client(rule); @@ -888,10 +863,7 @@ int vc_mgr_is_command_format_supported(int format, bool* support) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == support) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter, support is NULL ptr"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == support, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -948,20 +920,12 @@ int vc_mgr_enable_command_type(int cmd_type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret; @@ -1003,20 +967,12 @@ int vc_mgr_disable_command_type(int cmd_type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret; @@ -1053,34 +1009,20 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - if (NULL == vc_cmd_list) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_cmd_list_s* list = NULL; list = (vc_cmd_list_s*)vc_cmd_list; SLOG(LOG_INFO, TAG_VCM, "[List] (%p) (%p)", list, list->list); - if (NULL == list->list) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid command list"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input command list"); int i; int ret; @@ -1134,10 +1076,7 @@ int vc_mgr_unset_command_list(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); int ret = -1; @@ -1172,12 +1111,8 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == file_path) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter!!"); - return VC_ERROR_INVALID_PARAMETER; - } else { - SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); - } + RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); + SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); /* check type */ if (VC_COMMAND_TYPE_FOREGROUND > type || VC_COMMAND_TYPE_EXCLUSIVE < type) { @@ -1193,18 +1128,12 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = vc_cmd_parser_delete_file(getpid(), type); if (0 != ret) @@ -1238,12 +1167,8 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == file_path) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter!! file_path is NULL ptr"); - return VC_ERROR_INVALID_PARAMETER; - } else { - SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); - } + RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); + SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1252,18 +1177,12 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); /* Only support to set background commands for preloaded application */ int ret = vc_json_set_commands_from_file(file_path, VC_COMMAND_TYPE_BACKGROUND, NULL); @@ -1300,20 +1219,12 @@ int vc_mgr_set_audio_type(const char* audio_id) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; /* Request */ @@ -1344,10 +1255,7 @@ int vc_mgr_get_audio_type(char** audio_id) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == audio_id) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == audio_id, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1357,20 +1265,12 @@ int vc_mgr_get_audio_type(char** audio_id) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); char* temp = NULL; @@ -1417,31 +1317,18 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - if (NULL == vc_cmd_list) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid Parameter"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid Parameter"); vc_cmd_list_h temp_list = NULL; if (0 != vc_cmd_list_create(&temp_list)) { @@ -1615,20 +1502,12 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); vc_mgr_client_set_recognition_mode(g_vc_m, mode); return VC_ERROR_NONE; @@ -1647,10 +1526,7 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) int ret = -1; - if (NULL == mode) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter, mode is NULL ptr"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == mode, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter, mode is NULL ptr"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1682,10 +1558,7 @@ int vc_mgr_set_private_data(const char* key, const char* data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == key) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == key, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1695,20 +1568,12 @@ int vc_mgr_set_private_data(const char* key, const char* data) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; ret = vc_mgr_tidl_request_set_private_data(g_vc_m->handle, key, data); @@ -1750,20 +1615,12 @@ int vc_mgr_get_private_data(const char* key, char** data) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; char* temp = NULL; @@ -1802,10 +1659,7 @@ int vc_mgr_set_domain(const char* domain) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == domain) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == domain, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1815,20 +1669,12 @@ int vc_mgr_set_domain(const char* domain) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; @@ -1862,10 +1708,7 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) return VC_ERROR_INVALID_PARAMETER; } - if (NULL == send_event) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == send_event, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1875,20 +1718,12 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; ret = vc_mgr_tidl_request_do_action(g_vc_m->handle, type, send_event); @@ -1935,20 +1770,12 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; ret = vc_mgr_tidl_send_specific_engine_request(g_vc_m->handle, engine_app_id, event, request); @@ -1984,20 +1811,12 @@ int vc_mgr_start(bool exclusive_command_option) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); /* Check internal state for async */ vc_internal_state_e internal_state = -1; @@ -2066,20 +1885,12 @@ int vc_mgr_stop(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: client state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_RECORDING) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'RECORDING'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_RECORDING, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'RECORDING'", service_state); /* Check internal state for async */ vc_internal_state_e internal_state = -1; @@ -2132,20 +1943,12 @@ int vc_mgr_cancel(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: client state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state == VC_SERVICE_STATE_NONE) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state == VC_SERVICE_STATE_NONE, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state is NONE"); vc_internal_state_e internal_state = -1; vc_mgr_client_get_internal_state(g_vc_m, &internal_state); @@ -2228,10 +2031,7 @@ int vc_mgr_get_recording_volume(float* volume) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == volume) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == volume, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_service_state_e service_state = -1; if (0 != vc_mgr_client_get_service_state(g_vc_m, &service_state)) { @@ -2240,10 +2040,7 @@ int vc_mgr_get_recording_volume(float* volume) } /* check state */ - if (VC_SERVICE_STATE_RECORDING != service_state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Service state is not 'RECORDING'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SERVICE_STATE_RECORDING != service_state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Service state is not 'RECORDING'"); *volume = g_volume_db; @@ -2361,10 +2158,7 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) void* all_user_data = NULL; vc_mgr_client_get_all_result_cb(g_vc_m, &all_callback, &all_user_data); - if (NULL == all_callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] All result callback is NULL"); - return; - } + RETM_IF(NULL == all_callback, TAG_VCM, "[ERROR] All result callback is NULL"); if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create command list"); @@ -2392,10 +2186,7 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) void* user_data = NULL; vc_mgr_client_get_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client result callback is NULL"); - return; - } + RETM_IF(NULL == callback, TAG_VCM, "[ERROR] Client result callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(event, vc_cmd_list, temp_text, user_data); @@ -2469,10 +2260,7 @@ static Eina_Bool __vc_mgr_notify_result(void *data) void* user_data = NULL; vc_mgr_client_get_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client result callback is NULL"); - return EINA_FALSE; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCM, "[ERROR] Client result callback is NULL"); if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create command list"); @@ -2519,10 +2307,7 @@ void __vc_mgr_cb_pre_result(vc_pre_result_event_e event, const char* pre_result) void* user_data = NULL; vc_mgr_client_get_pre_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client pre result callback is NULL"); - return; - } + RETM_IF(NULL == callback, TAG_VCM, "[ERROR] Client pre result callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(event, pre_result, user_data); @@ -2544,10 +2329,7 @@ static Eina_Bool __vc_mgr_speech_detected(void *data) void* user_data = NULL; vc_mgr_client_get_speech_detected_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client speech detected callback is NULL"); - return EINA_FALSE; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCM, "[ERROR] Client speech detected callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(user_data); @@ -2575,8 +2357,7 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2585,10 +2366,7 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_all_result_cb(g_vc_m, callback, user_data); @@ -2615,10 +2393,7 @@ int vc_mgr_unset_all_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_all_result_cb(g_vc_m, NULL, NULL); @@ -2636,8 +2411,7 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2646,10 +2420,7 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_result_cb(g_vc_m, callback, user_data); @@ -2674,10 +2445,7 @@ int vc_mgr_unset_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_result_cb(g_vc_m, NULL, NULL); @@ -2695,8 +2463,7 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2705,10 +2472,7 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set pre result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_pre_result_cb(g_vc_m, callback, user_data); @@ -2733,10 +2497,7 @@ int vc_mgr_unset_pre_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset pre result callback : Current state is not 'Initialize'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_pre_result_cb(g_vc_m, NULL, NULL); @@ -2763,10 +2524,7 @@ int vc_mgr_get_error_message(char** err_msg) return VC_ERROR_INVALID_STATE; } - if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == err_msg, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); if (false == g_err_callback_status) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not in error callback"); @@ -2895,10 +2653,7 @@ int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_state_changed_cb(g_vc_m, callback, user_data); @@ -2924,10 +2679,7 @@ int vc_mgr_unset_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_state_changed_cb(g_vc_m, NULL, NULL); @@ -3002,10 +2754,7 @@ int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, vo } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_service_state_changed_cb(g_vc_m, callback, user_data); @@ -3031,10 +2780,7 @@ int vc_mgr_unset_service_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_service_state_changed_cb(g_vc_m, NULL, NULL); return VC_ERROR_NONE; @@ -3061,10 +2807,7 @@ int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set speech detected callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_speech_detected_cb(g_vc_m, callback, user_data); @@ -3090,10 +2833,7 @@ int vc_mgr_unset_speech_detected_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_speech_detected_cb(g_vc_m, NULL, NULL); return VC_ERROR_NONE; @@ -3110,8 +2850,7 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3120,10 +2859,7 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_current_lang_changed_cb(g_vc_m, callback, user_data); @@ -3149,10 +2885,7 @@ int vc_mgr_unset_current_language_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_current_lang_changed_cb(g_vc_m, NULL, NULL); @@ -3170,8 +2903,7 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3180,10 +2912,7 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_error_cb(g_vc_m, callback, user_data); @@ -3208,10 +2937,7 @@ int vc_mgr_unset_error_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_error_cb(g_vc_m, NULL, NULL); @@ -3307,10 +3033,7 @@ int __vc_mgr_cb_feedback_streaming(int pid, int utt_id, vc_feedback_event_e even /* add feedback data */ vc_feedback_data_s* temp_feedback_data = NULL; temp_feedback_data = (vc_feedback_data_s*)calloc(1, sizeof(vc_feedback_data_s)); - if (NULL == temp_feedback_data) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Out of memory"); - return VC_ERROR_OUT_OF_MEMORY; - } + RETVM_IF(NULL == temp_feedback_data, VC_ERROR_OUT_OF_MEMORY, TAG_VCM, "[ERROR] Out of memory"); SLOG(LOG_INFO, TAG_VCM, "[INFO] feedback streaming before queing"); temp_feedback_data->data = NULL; @@ -3367,8 +3090,7 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3377,10 +3099,7 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_dialog_request_cb(g_vc_m, callback, user_data); @@ -3405,10 +3124,7 @@ int vc_mgr_unset_dialog_request_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_dialog_request_cb(g_vc_m, NULL, NULL); @@ -3426,8 +3142,7 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3436,10 +3151,7 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set private data set callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Set private data set callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_set_cb(g_vc_m, callback, user_data); @@ -3464,10 +3176,7 @@ int vc_mgr_unset_private_data_set_cb(void) } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset private data set callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Unset private data set callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_set_cb(g_vc_m, NULL, NULL); @@ -3485,8 +3194,7 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3495,10 +3203,7 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba } /* check state*/ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set private data requested callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Set private data requested callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_requested_cb(g_vc_m, callback, user_data); @@ -3523,10 +3228,7 @@ int vc_mgr_unset_private_data_requested_cb(void) } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset private data requested callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Unset private data requested callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_requested_cb(g_vc_m, NULL, NULL); @@ -3726,8 +3428,7 @@ int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callba return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3736,10 +3437,7 @@ int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callba } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set specific engine result callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_specific_engine_result_cb(g_vc_m, callback, user_data); @@ -3758,10 +3456,7 @@ int vc_mgr_unset_specific_engine_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset specific engine result callback : Current state(%d) is not 'Initialize'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_specific_engine_result_cb(g_vc_m, NULL, NULL); @@ -3774,10 +3469,7 @@ void __vc_mgr_cb_specific_engine_result(const char* engine_app_id, const char* e void* user_data = NULL; vc_mgr_client_get_specific_engine_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client specific engine result callback is NULL"); - return; - } + RETM_IF(NULL == callback, TAG_VCM, "[ERROR] Client specific engine result callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(engine_app_id, event, result, user_data); @@ -3800,8 +3492,7 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3810,10 +3501,7 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set feedback audio format callback : Current state is not 'Initialized' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Set feedback audio format callback : Current state is not 'Initialized'"); vc_mgr_client_set_feedback_audio_format_cb(g_vc_m, callback, user_data); @@ -3841,10 +3529,7 @@ int vc_mgr_unset_feedback_audio_format_cb() } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset feedback audio format callback : Current state is not 'Initialized' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Unset feedback audio format callback : Current state is not 'Initialized'"); vc_mgr_client_set_feedback_audio_format_cb(g_vc_m, NULL, NULL); @@ -3865,8 +3550,7 @@ int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); pthread_mutex_lock(&g_feedback_streaming_cb_mutex); @@ -3943,8 +3627,7 @@ int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* us return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); pthread_mutex_lock(&g_vc_tts_streaming_cb_mutex); @@ -4141,10 +3824,7 @@ int vc_mgr_start_feedback(void) } /* check state */ - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Start feedback : Current state is not 'Ready' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Start feedback : Current state is not 'Ready' (%d)", state); #if 1 bool is_exist = ecore_thread_check(g_feedback_thread); @@ -4184,10 +3864,7 @@ int vc_mgr_stop_feedback(void) } /* check state */ - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state); #if 1 int ret = -1; @@ -4245,20 +3922,12 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_mgr_client_get_service_state(g_vc_m, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = vc_mgr_tidl_send_utterance_status(pid, utt_id, utt_status); if (0 != ret) @@ -4320,10 +3989,7 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* return VC_ERROR_INVALID_PARAMETER; } - if (NULL == buffer) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] buffer is invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == buffer, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state = VC_STATE_NONE; int ret = vc_mgr_client_get_client_state(g_vc_m, &state); @@ -4333,11 +3999,7 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* return VC_ERROR_INVALID_STATE; } - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); vc_service_state_e service_state = VC_SERVICE_STATE_NONE; ret = vc_mgr_client_get_service_state(g_vc_m, &service_state); diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index 42c8017..314daf9 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -81,7 +81,7 @@ static void __on_connected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* unsigned int pid = (uintptr_t)user_data; vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = true; info->connection_requesting = false; @@ -95,7 +95,7 @@ static void __on_disconnected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, vo unsigned int pid = (uintptr_t)user_data; vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = false; info->connection_requesting = false; @@ -110,7 +110,7 @@ static void __on_rejected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* unsigned int pid = (uintptr_t)user_data; vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connection_requesting = false; info->register_notify_callback_invoked = false; @@ -243,7 +243,7 @@ int vc_setting_tidl_close_connection() int pid = getpid(); vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (0 != rpc_port_proxy_vc_setting_proxy_vc_setting_destroy(info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect"); @@ -265,7 +265,7 @@ int vc_setting_tidl_request_hello() int pid = getpid(); vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (!info->connected) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()"); @@ -298,8 +298,8 @@ int vc_setting_tidl_request_set_language(int pid, const char* language) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_setting_tidl_request_set_language"); vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_setting_proxy_vc_setting_invoke_set_language(info->rpc_h, pid, language); if (RPC_PORT_ERROR_NONE != ret) { diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 61ea8ea..33d91a5 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -90,7 +90,7 @@ static void __on_connected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) unsigned int pid = (uintptr_t)user_data; vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = true; info->connection_requesting = false; @@ -104,7 +104,7 @@ static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) unsigned int pid = (uintptr_t)user_data; vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = false; info->connection_requesting = false; @@ -119,7 +119,7 @@ static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) unsigned int pid = (uintptr_t)user_data; vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connection_requesting = false; info->register_notify_callback_invoked = false; @@ -378,7 +378,7 @@ int vc_tidl_close_connection() int pid = getpid(); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (0 != rpc_port_proxy_vc_proxy_vc_destroy(info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect"); @@ -400,7 +400,7 @@ int vc_tidl_request_hello() int pid = getpid(); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (!info->connected) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()"); @@ -433,8 +433,8 @@ int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* d SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_initialize"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -452,8 +452,8 @@ int vc_tidl_request_finalize(int pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_finalize"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -471,8 +471,8 @@ int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_command"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { @@ -490,8 +490,8 @@ int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_unset_command"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { @@ -510,8 +510,8 @@ int vc_tidl_request_set_foreground(int pid, bool value) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_foreground"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); if (RPC_PORT_ERROR_NONE != ret) { @@ -529,8 +529,8 @@ int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* c SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_server_dialog"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential); if (RPC_PORT_ERROR_NONE != ret) { @@ -549,8 +549,8 @@ int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* u SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_dialog"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous); if (RPC_PORT_ERROR_NONE != ret) { @@ -568,8 +568,8 @@ int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_is_system_command_valid"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid); if (RPC_PORT_ERROR_NONE != ret) { @@ -588,8 +588,8 @@ int vc_tidl_request_auth_enable(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_enable"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -607,8 +607,8 @@ int vc_tidl_request_auth_disable(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_disable"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -626,8 +626,8 @@ int vc_tidl_request_auth_start(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_start"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -645,8 +645,8 @@ int vc_tidl_request_auth_stop(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_stop"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -664,8 +664,8 @@ int vc_tidl_request_auth_cancel(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_cancel"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -684,8 +684,8 @@ int vc_tidl_request_request_tts(int pid, const char* text, const char* language, SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_tts"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); if (VC_ERROR_NONE != __invoke_register_feedback_callback(pid, info)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register feedback callback"); @@ -708,8 +708,8 @@ int vc_tidl_request_cancel_tts(int pid, int utt_id) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_cancel_tts"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); if (RPC_PORT_ERROR_NONE != ret) { @@ -727,8 +727,8 @@ int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_get_tts_audio_format"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type); if (RPC_PORT_ERROR_NONE != ret) { diff --git a/client/vc_widget.c b/client/vc_widget.c index 5161784..d4816f0 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -168,10 +168,7 @@ int vc_widget_initialize(vc_h* vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); if (0 == vc_widget_client_get_count()) { if (0 != vc_widget_tidl_open_connection()) { @@ -208,7 +205,7 @@ int vc_widget_initialize(vc_h* vc_w) SLOG(LOG_DEBUG, TAG_VCW, "[Success] uid(%d)", (*vc_w)->handle); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Initialize DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; @@ -285,7 +282,6 @@ int vc_widget_deinitialize(vc_h vc_w) pthread_mutex_lock(&g_w_init_mutex); if (false == vc_widget_client_is_valid(vc_w)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] NOT initialized"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -338,7 +334,7 @@ int vc_widget_deinitialize(vc_h vc_w) } } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Deinitialize DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; @@ -365,8 +361,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_DEBUG, TAG_VCW, "@@@ type(%d) is NOT valid", type); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - SLOG(LOG_DEBUG, TAG_VCW, ""); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ Focus changed DONE"); return ECORE_CALLBACK_RENEW; } @@ -570,7 +565,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) } g_w_prepare_thread = NULL; - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ Start prepare thread DONE"); return; } @@ -597,7 +592,6 @@ int vc_widget_prepare(vc_h vc_w) vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -605,7 +599,6 @@ int vc_widget_prepare(vc_h vc_w) /* check state */ if (state != VC_STATE_INITIALIZED) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -613,7 +606,6 @@ int vc_widget_prepare(vc_h vc_w) vc_widget_s* widget = widget_get(vc_w); if (NULL == widget) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get widget handle"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -630,7 +622,7 @@ int vc_widget_prepare(vc_h vc_w) g_ask_to_cancel_preparing = false; g_w_prepare_thread = ecore_thread_run(__start_prepare_thread, __end_prepare_thread, __cancel_prepare_thread, (void*)vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Prepare DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } @@ -655,7 +647,6 @@ int vc_widget_unprepare(vc_h vc_w) vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -663,7 +654,6 @@ int vc_widget_unprepare(vc_h vc_w) /* check state */ if (state != VC_STATE_READY) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -673,7 +663,7 @@ int vc_widget_unprepare(vc_h vc_w) vc_widget_client_set_state(vc_w, VC_STATE_INITIALIZED); g_w_notify_state_timer = ecore_timer_add(0, __vc_widget_notify_state_changed, vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Unprepare DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } @@ -690,16 +680,11 @@ int vc_widget_enable_asr_result(vc_h vc_w, bool enable) vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); int ret = -1; @@ -711,7 +696,7 @@ int vc_widget_enable_asr_result(vc_h vc_w, bool enable) vc_widget_client_set_asr_result_enabled(vc_w, enable); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Enable asr result DONE"); return ret; } @@ -725,16 +710,11 @@ int vc_widget_foreach_supported_languages(vc_h vc_w, vc_supported_language_cb ca return VC_ERROR_NONE; } - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -745,7 +725,7 @@ int vc_widget_foreach_supported_languages(vc_h vc_w, vc_supported_language_cb ca SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get languages : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Foreach Supported Language DONE"); return VC_ERROR_NONE; } @@ -759,16 +739,11 @@ int vc_widget_get_current_language(vc_h vc_w, char** language) return VC_ERROR_NONE; } - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -779,7 +754,7 @@ int vc_widget_get_current_language(vc_h vc_w, char** language) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get current languages : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get Current Language DONE"); return ret; } @@ -793,15 +768,11 @@ int vc_widget_get_state(vc_h vc_w, vc_state_e* state) return VC_ERROR_NONE; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (0 != vc_widget_client_get_state(vc_w, &temp)) { SLOG(LOG_DEBUG, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -814,7 +785,7 @@ int vc_widget_get_state(vc_h vc_w, vc_state_e* state) default: SLOG(LOG_ERROR, TAG_VCW, "Invalid state"); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get State DONE"); return VC_ERROR_NONE; } @@ -828,23 +799,15 @@ int vc_widget_get_service_state(vc_h vc_w, vc_service_state_e* state) return VC_ERROR_NONE; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (0 != vc_widget_client_get_state(vc_w, &temp)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } - if (temp != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(temp != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); /* get service state */ vc_service_state_e service_state; @@ -863,7 +826,7 @@ int vc_widget_get_service_state(vc_h vc_w, vc_service_state_e* state) default: SLOG(LOG_ERROR, TAG_VCW, "Invalid service state"); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get Service State DONE"); return VC_ERROR_NONE; } @@ -880,16 +843,11 @@ int vc_widget_set_foreground(vc_h vc_w, bool value) vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); SLOG(LOG_DEBUG, TAG_VCW, "Set foreground : pid(%d) value(%s)", getpid(), value ? "true" : "false"); int ret = vc_widget_tidl_set_foreground(getpid(), value); @@ -898,7 +856,7 @@ int vc_widget_set_foreground(vc_h vc_w, bool value) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Set foreground state DONE"); return VC_ERROR_NONE; } @@ -910,7 +868,6 @@ int vc_widget_is_format_supported(vc_h vc_w, vc_cmd_format_e format, bool* suppo vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -931,7 +888,7 @@ int vc_widget_is_format_supported(vc_h vc_w, vc_cmd_format_e format, bool* suppo SLOG(LOG_ERROR, TAG_VCW, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Is command type supported DONE"); return VC_ERROR_NONE; } @@ -1117,23 +1074,17 @@ int vc_widget_cancel(vc_h vc_w) vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); /* Check service state */ vc_service_state_e service_state = -1; vc_widget_client_get_service_state(vc_w, &service_state); if (service_state != VC_SERVICE_STATE_RECORDING && service_state != VC_SERVICE_STATE_PROCESSING) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: service state is not 'RECORDING' or 'PROCESSING'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1144,7 +1095,7 @@ int vc_widget_cancel(vc_h vc_w) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request cancel : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Cancel Recognition DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1156,10 +1107,8 @@ static void __vc_widget_notify_error(void *data) vc_error_cb callback = NULL; void* user_data; int reason; - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return; - } + + RETM_IF(NULL == vc_w, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_widget_client_get_error_cb(vc_w, &callback, &user_data); vc_widget_client_get_error(vc_w, &reason); @@ -1198,10 +1147,7 @@ int __vc_widget_cb_error(int reason, int daemon_pid, char* msg) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[WARNING] not connected client yet"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] not connected client yet"); if (VC_ERROR_SERVICE_RESET == reason) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] VC daemon reset"); @@ -1369,10 +1315,7 @@ static Eina_Bool __vc_widget_notify_result(void *data) if (NULL != widget_data) { vc_w = widget_data->vc; vc_widget_client_get_result_cb(vc_w, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Client result callback is NULL"); - return EINA_FALSE; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCW, "[ERROR] Client result callback is NULL"); vc_cmd_print_list(vc_cmd_list); @@ -1446,10 +1389,7 @@ bool __vc_widget_cb_asr_result(int event, const char* asr_result) static Eina_Bool __vc_widget_notify_state_changed(void *data) { vc_h vc_w = (vc_h)data; - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); @@ -1482,14 +1422,10 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1497,10 +1433,7 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_result_cb(vc_w, callback, user_data); @@ -1514,10 +1447,7 @@ int vc_widget_unset_result_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1527,10 +1457,7 @@ int vc_widget_unset_result_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_result_cb(vc_w, NULL, NULL); @@ -1544,14 +1471,10 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1560,10 +1483,7 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_show_tooltip_cb(vc_w, callback, user_data); @@ -1577,10 +1497,7 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1590,10 +1507,7 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_show_tooltip_cb(vc_w, NULL, NULL); @@ -1607,10 +1521,7 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1620,10 +1531,7 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_send_command_list_cb(vc_w, callback, user_data); @@ -1637,10 +1545,7 @@ int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1650,10 +1555,7 @@ int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_send_command_list_cb(vc_w, NULL, NULL); @@ -1713,10 +1615,7 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1726,10 +1625,7 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_service_state_changed_cb(vc_w, callback, user_data); @@ -1743,10 +1639,7 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1756,10 +1649,7 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_service_state_changed_cb(vc_w, NULL, NULL); @@ -1773,14 +1663,10 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1789,10 +1675,7 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_state_changed_cb(vc_w, callback, user_data); @@ -1806,10 +1689,7 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1819,10 +1699,7 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_state_changed_cb(vc_w, NULL, NULL); @@ -1836,14 +1713,10 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1852,10 +1725,7 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_asr_result_cb(vc_w, callback, user_data); @@ -1869,10 +1739,7 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1882,10 +1749,7 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_asr_result_cb(vc_w, NULL, NULL); @@ -1899,14 +1763,10 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1915,10 +1775,7 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_current_lang_changed_cb(vc_w, callback, user_data); @@ -1932,10 +1789,7 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1945,10 +1799,7 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_current_lang_changed_cb(vc_w, NULL, NULL); @@ -1962,14 +1813,10 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1978,10 +1825,7 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_error_cb(vc_w, callback, user_data); @@ -1995,10 +1839,7 @@ int vc_widget_unset_error_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -2008,10 +1849,7 @@ int vc_widget_unset_error_cb(vc_h vc_w) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_error_cb(vc_w, NULL, NULL); diff --git a/common/vc_main.h b/common/vc_main.h index 6b6d400..3090848 100644 --- a/common/vc_main.h +++ b/common/vc_main.h @@ -65,20 +65,21 @@ typedef struct vc_s *vc_h; #define COLOR_LIGHTBLUE "\033[0;37m" #define COLOR_END "\033[0;m" -#define PERR(fmt, args...) LOGE(COLOR_RED "* Critical * " fmt COLOR_END, ##args) +// #define PERR(fmt, args...) LOGE(COLOR_RED "* Critical * " fmt COLOR_END, ##args) +#define PERR(tag, fmt, args...) SLOG(LOG_ERROR, tag, COLOR_RED "* Critical * " fmt COLOR_END, ##args) -#define RETM_IF(expr, fmt, arg...) \ +#define RETM_IF(expr, tag, fmt, arg...) \ do { \ if (expr) { \ - PERR(fmt, ##arg); \ + PERR(tag, fmt, ##arg); \ return; \ } \ } while (0) -#define RETVM_IF(expr, val, fmt, arg...) \ +#define RETVM_IF(expr, val, tag, fmt, arg...) \ do { \ if (expr) { \ - PERR(fmt, ##arg); \ + PERR(tag, fmt, ##arg); \ return (val); \ } \ } while (0) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index b7709f3..ac18b4b 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -131,34 +131,40 @@ static void __request_tidl_connect(vcd_client_type_e type, int pid) } } -void __send_msg(bundle* msg, vcd_client_type_e type, int pid) +void __send_msg_to_mgr(bundle* msg) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] send msg start"); - - if (VCD_CLIENT_TYPE_MANAGER == type) { - pthread_mutex_lock(&g_mgr_tidl_info_mutex); + pthread_mutex_lock(&g_mgr_tidl_info_mutex); - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } - rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } - if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; +} + +void __send_msg(bundle* msg, vcd_client_type_e type, int pid) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] send msg start"); + + if (VCD_CLIENT_TYPE_MANAGER == type) { + __send_msg_to_mgr(msg); } else if (VCD_CLIENT_TYPE_NORMAL == type) { pthread_mutex_lock(&g_client_tidl_info_mutex); @@ -218,29 +224,7 @@ void __send_signal(bundle* msg, vcd_client_type_e type) SLOG(LOG_INFO, TAG_VCD, "[TIDL] send signal start"); if (VCD_CLIENT_TYPE_MANAGER == type) { - pthread_mutex_lock(&g_mgr_tidl_info_mutex); - - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - - rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - - if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + __send_msg_to_mgr(msg); } /* signal to MANAGER */ else if (VCD_CLIENT_TYPE_NORMAL == type) { pthread_mutex_lock(&g_client_tidl_info_mutex); -- 2.7.4 From ff8aeee9682f924e59b8bc768c7ae62c0d0c9c8d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 6 Jul 2022 15:10:13 +0900 Subject: [PATCH 10/16] Remove unnecessary logs Change-Id: I7f4316fba8a62061cbe819465f2520e10e187fcb Signed-off-by: sooyeon --- client/vc.c | 37 ++------- client/vc_mgr.c | 98 +++++++--------------- client/vc_mgr_tidl.c | 35 ++------ client/vc_setting.c | 213 ++++++++++-------------------------------------- client/vc_widget_tidl.c | 8 +- server/vcd_server.c | 13 ++- server/vcd_tidl.c | 141 +++++++++++++------------------- 7 files changed, 154 insertions(+), 391 deletions(-) diff --git a/client/vc.c b/client/vc.c index 1b6d87a..07234ba 100644 --- a/client/vc.c +++ b/client/vc.c @@ -341,7 +341,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_DEBUG, TAG_VCC, "@@@ type(%d) is NOT valid", type); } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Focus changed DONE"); return ECORE_CALLBACK_RENEW; } @@ -451,7 +451,6 @@ int vc_deinitialize(void) if (false == vc_client_is_valid(g_vc)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NOT initialized"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -499,7 +498,7 @@ int vc_deinitialize(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to close connection"); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Deinitialize DONE"); return VC_ERROR_NONE; } @@ -621,7 +620,7 @@ static Eina_Bool __vc_connect_daemon(void *data) return EINA_FALSE; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Connect daemon DONE"); return EINA_FALSE; } @@ -684,7 +683,6 @@ int vc_prepare(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -712,7 +710,6 @@ int vc_prepare_sync(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -774,7 +771,6 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -808,7 +804,6 @@ int vc_get_current_language(char** language) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -841,7 +836,6 @@ int vc_get_state(vc_state_e* state) vc_state_e temp; if (0 != vc_client_get_client_state(g_vc, &temp)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1039,7 +1033,6 @@ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1173,7 +1166,6 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1298,7 +1290,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1308,7 +1299,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) /* check type */ if ((VC_COMMAND_TYPE_FOREGROUND != type) && (VC_COMMAND_TYPE_BACKGROUND != type)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command type: input type is %d", type); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -1760,7 +1750,6 @@ int vc_get_result(vc_result_cb callback, void* user_data) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2105,7 +2094,6 @@ int vc_set_invocation_name(const char* name) int ret = vc_client_get_client_state(g_vc, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return ret; } @@ -2494,7 +2482,6 @@ int vc_auth_start(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2551,7 +2538,7 @@ int vc_auth_start(void) } } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request start DONE"); return ret; } @@ -2563,7 +2550,6 @@ int vc_auth_stop(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2620,7 +2606,7 @@ int vc_auth_stop(void) } } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request stop DONE"); return ret; } @@ -2632,7 +2618,6 @@ int vc_auth_cancel(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2644,7 +2629,6 @@ int vc_auth_cancel(void) vc_client_get_service_state(g_vc, &service_state); if (service_state != VC_SERVICE_STATE_RECORDING && service_state != VC_SERVICE_STATE_PROCESSING) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'RECORDING' or 'PROCESSING'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2692,7 +2676,7 @@ int vc_auth_cancel(void) } } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request cancel DONE"); return ret; } @@ -2822,7 +2806,6 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2862,7 +2845,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request tts DONE"); return ret; } @@ -2884,7 +2867,6 @@ int vc_tts_cancel(int utt_id) if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2929,7 +2911,7 @@ int vc_tts_cancel(int utt_id) } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Cancel tts DONE"); return ret; } @@ -2951,7 +2933,6 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2991,7 +2972,7 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get tts audio format DONE"); return ret; } diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 061f0be..813ee44 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -334,7 +334,7 @@ int vc_mgr_initialize(void) */ SLOG(LOG_ERROR, TAG_VCM, "[Success] pid(%d)", g_vc_m->handle); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Initialize DONE"); return VC_ERROR_NONE; } @@ -365,7 +365,6 @@ int vc_mgr_deinitialize(void) if (false == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NOT initialized"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -425,7 +424,7 @@ int vc_mgr_deinitialize(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to close connection"); } - SLOG(LOG_ERROR, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Deinitialize DONE"); return VC_ERROR_NONE; } @@ -578,7 +577,6 @@ int vc_mgr_prepare(void) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -595,7 +593,7 @@ int vc_mgr_prepare(void) SLOG(LOG_INFO, TAG_VCM, "[INFO] timer handle is already created"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Calling Prepare DONE"); return VC_ERROR_NONE; } @@ -616,7 +614,6 @@ int vc_mgr_unprepare(void) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -628,7 +625,7 @@ int vc_mgr_unprepare(void) vc_mgr_client_set_client_state(g_vc_m, VC_STATE_INITIALIZED); ecore_timer_add(0, __vc_mgr_notify_state_changed, g_vc_m); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Unprepare DONE"); return VC_ERROR_NONE; } @@ -651,7 +648,6 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -662,7 +658,7 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get languages : %s", __vc_mgr_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Foreach Supported Language DONE"); return VC_ERROR_NONE; } @@ -718,7 +714,6 @@ int vc_mgr_get_state(vc_state_e* state) temp = VC_STATE_NONE; } else if (0 != vc_mgr_client_get_client_state(g_vc_m, &temp)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -731,7 +726,7 @@ int vc_mgr_get_state(vc_state_e* state) default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get State DONE"); return VC_ERROR_NONE; } @@ -758,10 +753,7 @@ int vc_mgr_get_service_state(vc_service_state_e* state) } /* check state */ - if (client_state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(client_state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Current state is not 'READY'"); /* get service state */ vc_service_state_e service_state; @@ -780,7 +772,7 @@ int vc_mgr_get_service_state(vc_service_state_e* state) default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get Service State DONE"); return VC_ERROR_NONE; } @@ -801,7 +793,6 @@ int vc_mgr_set_demandable_client_rule(const char* rule) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -821,7 +812,7 @@ int vc_mgr_set_demandable_client_rule(const char* rule) return VC_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set Demandable client rule(%s) DONE", rule); return VC_ERROR_NONE; } @@ -868,7 +859,6 @@ int vc_mgr_is_command_format_supported(int format, bool* support) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -889,7 +879,7 @@ int vc_mgr_is_command_format_supported(int format, bool* support) SLOG(LOG_ERROR, TAG_VCM, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Is command type supported DONE"); return VC_ERROR_NONE; } @@ -915,7 +905,6 @@ int vc_mgr_enable_command_type(int cmd_type) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -936,7 +925,7 @@ int vc_mgr_enable_command_type(int cmd_type) SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Success to enable the command type(%d)", cmd_type); } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Enable Command Type DONE, ret(%d)", ret); return ret; } @@ -962,7 +951,6 @@ int vc_mgr_disable_command_type(int cmd_type) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -983,7 +971,7 @@ int vc_mgr_disable_command_type(int cmd_type) SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Success to disable the command type(%d)", cmd_type); } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Disable Command Type DONE, ret(%d)", ret); return ret; } @@ -1004,7 +992,6 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1051,7 +1038,7 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) } } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list DONE, ret(%d)", ret); return ret; } @@ -1092,7 +1079,7 @@ int vc_mgr_unset_command_list(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to delete file, type(%d), ret(%d)", i, ret); } - SLOG(LOG_ERROR, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unset Command list DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1117,7 +1104,6 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) /* check type */ if (VC_COMMAND_TYPE_FOREGROUND > type || VC_COMMAND_TYPE_EXCLUSIVE < type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid command type: input type is %d", type); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -1149,7 +1135,7 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) } } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list from file DONE, ret(%d)", ret); return ret; } @@ -1189,7 +1175,7 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to insert preloaded commands into db"); - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set preloaded command list DONE, ret(%d)", ret); return ret; } @@ -1214,7 +1200,6 @@ int vc_mgr_set_audio_type(const char* audio_id) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1237,7 +1222,7 @@ int vc_mgr_set_audio_type(const char* audio_id) vc_mgr_client_set_audio_type(g_vc_m, audio_id); } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set audio type DONE, ret(%d)", ret); return ret; } @@ -1260,7 +1245,6 @@ int vc_mgr_get_audio_type(char** audio_id) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1435,7 +1419,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) iter = g_slist_nth(client_info_list, 0); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Foreach current commands DONE"); return VC_ERROR_NONE; } @@ -1469,7 +1453,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_INFO, TAG_VCM, "[Manager] No background commands"); } - SLOG(LOG_ERROR, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Foreach current commands DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1497,7 +1481,6 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1531,7 +1514,6 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1563,7 +1545,6 @@ int vc_mgr_set_private_data(const char* key, const char* data) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1584,7 +1565,7 @@ int vc_mgr_set_private_data(const char* key, const char* data) SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Set private data"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set private data DONE"); return VC_ERROR_NONE; } @@ -1610,7 +1591,6 @@ int vc_mgr_get_private_data(const char* key, char** data) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1640,7 +1620,7 @@ int vc_mgr_get_private_data(const char* key, char** data) temp = NULL; } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get private data DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1664,7 +1644,6 @@ int vc_mgr_set_domain(const char* domain) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1685,7 +1664,7 @@ int vc_mgr_set_domain(const char* domain) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set domain"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set domain DONE"); return VC_ERROR_NONE; } @@ -1713,7 +1692,6 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1733,7 +1711,7 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) } else { SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] do action"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] do action DONE"); return VC_ERROR_NONE; } @@ -1765,7 +1743,6 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1785,7 +1762,7 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e } else { SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] specific engine request"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] send specific engine request DONE"); return VC_ERROR_NONE; } @@ -1806,7 +1783,6 @@ int vc_mgr_start(bool exclusive_command_option) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1859,7 +1835,7 @@ int vc_mgr_start(bool exclusive_command_option) g_prev_volume_db = 0; g_cur_volume_db = 0; - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request start DONE, ret(%d)", ret); return ret; } @@ -1880,7 +1856,6 @@ int vc_mgr_stop(void) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1917,7 +1892,7 @@ int vc_mgr_stop(void) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Stop recognition"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request stop DONE"); return ret; } @@ -1938,7 +1913,6 @@ int vc_mgr_cancel(void) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1975,7 +1949,7 @@ int vc_mgr_cancel(void) vc_mgr_client_set_exclusive_command(g_vc_m, false); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request cancel DONE"); return ret; } @@ -2105,7 +2079,6 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) if (VC_RECOGNITION_MODE_RESTART_CONTINUOUSLY != recognition_mode) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'PROCESSING' and mode is not 'Restart continuously'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } } @@ -2136,7 +2109,7 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) vc_mgr_client_unset_all_result(g_vc_m); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Select result DONE"); return VC_ERROR_NONE; } @@ -2537,7 +2510,7 @@ int vc_mgr_get_error_message(char** err_msg) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get error message"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get error message DONE"); return ret; } @@ -3917,7 +3890,6 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -3935,7 +3907,7 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e else SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Send utterance status"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] send utterance status DONE"); return ret; } @@ -3995,7 +3967,6 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4005,13 +3976,11 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* ret = vc_mgr_client_get_service_state(g_vc_m, &service_state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } if (VC_SERVICE_STATE_READY != service_state && VC_SERVICE_STATE_RECORDING != service_state) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY' and 'RECORDING', state(%d)", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4048,7 +4017,6 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4056,7 +4024,6 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) ret = vc_mgr_client_get_service_state(g_vc_m, &service_state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4087,7 +4054,6 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) } else { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'INITIALIZED', state(%d)", state); SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current service state is not 'READY', service_state(%d)", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4225,13 +4191,11 @@ int vc_mgr_change_system_volume(vc_system_volume_event_e event) int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } if (state != VC_STATE_READY && state != VC_STATE_INITIALIZED) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY' and not 'INITIALIZED', state(%d)", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4260,13 +4224,11 @@ int vc_mgr_recover_system_volume(void) int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } if (state != VC_STATE_READY && state != VC_STATE_INITIALIZED) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY' and not 'INITIALIZED', state(%d)", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index eaa5ddf..18b7ac8 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -132,8 +132,6 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_INFO, TAG_VCM, "@@@ Get Speech detected"); __vc_mgr_cb_speech_detected(); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_SPEECH_DETECTED */ else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT))) { @@ -144,8 +142,6 @@ static void __notify_cb(void *user_data, bundle *msg) if (val) { __vc_mgr_cb_all_result((vc_result_type_e)atoi(val)); } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_ALL_RESULT */ else if (0 == strncmp(VCD_MANAGER_METHOD_PRE_RESULT, method, strlen(VCD_MANAGER_METHOD_PRE_RESULT))) { @@ -159,8 +155,6 @@ static void __notify_cb(void *user_data, bundle *msg) if (NULL != pre_result) { __vc_mgr_cb_pre_result((vc_pre_result_event_e)atoi(event), pre_result); } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_PRE_RESULT */ else if (0 == strncmp(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT, method, strlen(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT))) { @@ -189,9 +183,6 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_INFO, TAG_VCM, "@@@ Get System Result"); __vc_mgr_cb_system_result(); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VCD_MANAGER_METHOD_RESULT */ else if (0 == strncmp(VCD_MANAGER_METHOD_DIALOG, method, strlen(VCD_MANAGER_METHOD_DIALOG))) { @@ -212,8 +203,6 @@ static void __notify_cb(void *user_data, bundle *msg) utt_text = NULL; __vc_mgr_cb_dialog(atoi(pid), disp_text, utt_text, (bool)atoi(continous)); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_DIALOG */ else if (0 == strncmp(VCD_MANAGER_METHOD_ERROR, method, strlen(VCD_MANAGER_METHOD_ERROR))) { @@ -236,8 +225,6 @@ static void __notify_cb(void *user_data, bundle *msg) free(temp_msg); temp_msg = NULL; } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_ERROR */ else if (0 == strncmp(VCD_MANAGER_METHOD_SET_PRIVATE_DATA, method, strlen(VCD_MANAGER_METHOD_SET_PRIVATE_DATA))) { @@ -256,8 +243,6 @@ static void __notify_cb(void *user_data, bundle *msg) } else { SLOG(LOG_ERROR, TAG_VCM, "@@ got invalid pid(%d)", atoi(pid)); } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_SET_PRIVATE_DATA */ else if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT))) { @@ -271,8 +256,6 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_AUDIO_RATE, &rate); __vc_mgr_cb_feedback_audio_format(atoi(rate), (vc_audio_channel_e)atoi(channel), (vc_audio_type_e)atoi(audio_type)); - - SLOG(LOG_INFO, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT */ // TODO: uncomment this line after vcc done @@ -292,13 +275,13 @@ static void __notify_cb(void *user_data, bundle *msg) // SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false"); // __vc_mgr_cb_set_foreground(pid, (bool)value); - // SLOG(LOG_DEBUG, TAG_VCM, "@@@"); // } /* VCC_MANAGER_METHOD_SET_FOREGROUND */ else { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid msg"); } + SLOG(LOG_DEBUG, TAG_VCM, "@@@ __notify_cb DONE"); } static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_char_h data_in, bundle *msg) @@ -324,7 +307,7 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ __vc_mgr_cb_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len); free(buffer); - SLOG(LOG_INFO, TAG_VCM, "@@@"); + SLOG(LOG_INFO, TAG_VCM, "@@@ __send_buffer_cb DONE"); } /* VCD_MANAGER_METHOD_FEEDBACK_STREAMING */ else { @@ -423,7 +406,7 @@ static void __vcd_mgr_set_foreground_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_contex __vc_mgr_cb_set_foreground(pid, (bool)value); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Set foreground DONE"); } static int __vcd_mgr_get_private_data_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, const char *key, char **data, void *user_data) @@ -444,7 +427,7 @@ static int __vcd_mgr_get_private_data_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_conte temp_data = strdup("#NULL"); } *data = temp_data; - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request get private data DONE"); return ret; } @@ -461,7 +444,7 @@ static int __vcd_mgr_auth_enable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth enable DONE"); return ret; } @@ -478,7 +461,7 @@ static int __vcd_mgr_auth_disable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth disable DONE"); return ret; } @@ -495,7 +478,7 @@ static int __vcd_mgr_auth_start_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h c SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth start DONE"); return ret; } @@ -512,7 +495,7 @@ static int __vcd_mgr_auth_stop_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h co SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth stop DONE"); return ret; } @@ -529,7 +512,7 @@ static int __vcd_mgr_auth_cancel_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth cancel DONE"); return ret; } diff --git a/client/vc_setting.c b/client/vc_setting.c index 5f26cbe..aabd0b8 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -87,23 +87,17 @@ int vc_setting_initialize(void) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Initialize VC Setting"); - if (VC_SETTING_STATE_READY == g_state) { - SLOG(LOG_WARN, TAG_VCS, "[WARNING] VC Setting has already been initialized."); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_NONE; - } + RETVM_IF(VC_SETTING_STATE_READY == g_state, VC_ERROR_NONE, TAG_VCS, "[WARNING] VC Setting has already been initialized."); int ret = vc_config_mgr_initialize(getpid() + VC_SETTING_CONFIG_HANDLE); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to initialize config manager"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); return VC_ERROR_OPERATION_FAILED; } ret = vc_config_mgr_set_lang_cb(getpid() + VC_SETTING_CONFIG_HANDLE, __config_lang_changed_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to initialize config manager"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); vc_config_mgr_finalize(getpid() + VC_SETTING_CONFIG_HANDLE); return VC_ERROR_OPERATION_FAILED; } @@ -113,7 +107,7 @@ int vc_setting_initialize(void) g_state = VC_SETTING_STATE_READY; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Initialize VC Setting DONE"); return VC_ERROR_NONE; } @@ -122,11 +116,7 @@ int vc_setting_deinitialize() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Deinitialize VC Setting"); - if (VC_SETTING_STATE_READY != g_state) { - SLOG(LOG_WARN, TAG_VCS, "[WARNING] VC Setting is not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_READY != g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[WARNING] VC Setting is not initialized"); vc_config_mgr_unset_lang_cb(getpid() + VC_SETTING_CONFIG_HANDLE); vc_config_mgr_unset_engine_cb(getpid() + VC_SETTING_CONFIG_HANDLE); @@ -134,7 +124,7 @@ int vc_setting_deinitialize() g_state = VC_SETTING_STATE_NONE; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Deinitialize VC Setting DONE"); return VC_ERROR_NONE; } @@ -148,19 +138,9 @@ int vc_setting_foreach_supported_engines(vc_setting_supported_engine_cb callback { SLOG(LOG_DEBUG, TAG_VCS, "===== Foreach supported engines"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Callback is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); SLOG(LOG_DEBUG, TAG_VCS, "===== Foreach supported engines 11"); g_engine_cb = callback; @@ -173,8 +153,6 @@ int vc_setting_foreach_supported_engines(vc_setting_supported_engine_cb callback SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Foreach supported engines"); } - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); return ret; } @@ -183,19 +161,9 @@ int vc_setting_get_engine(char** engine_id) { SLOG(LOG_DEBUG, TAG_VCS, "===== Get current engine"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == engine_id) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Engine id is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == engine_id, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Engine id is NULL"); int ret = vc_config_mgr_get_engine(engine_id); if (0 != ret) { @@ -204,8 +172,6 @@ int vc_setting_get_engine(char** engine_id) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get current engine"); } - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); return ret; } @@ -214,19 +180,9 @@ int vc_setting_set_engine(const char* engine_appid) { SLOG(LOG_DEBUG, TAG_VCS, "===== Set current engine"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == engine_appid) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Engine appid is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == engine_appid, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Engine appid is NULL"); SECURE_SLOG(LOG_DEBUG, TAG_VCS, "New engine appid : %s", engine_appid); @@ -237,8 +193,6 @@ int vc_setting_set_engine(const char* engine_appid) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Set current engine"); } - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); return ret; } @@ -247,17 +201,9 @@ int vc_setting_foreach_supported_languages(vc_setting_supported_language_cb call { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Foreach supported languages"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_language_list((vc_supported_language_cb)callback, user_data); if (0 != ret) { @@ -266,7 +212,7 @@ int vc_setting_foreach_supported_languages(vc_setting_supported_language_cb call SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Foreach supported languages"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Foreach supported languages DONE"); return ret; } @@ -275,17 +221,9 @@ int vc_setting_get_language(char** language) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get default language"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_default_language(language); if (0 != ret) { @@ -294,7 +232,7 @@ int vc_setting_get_language(char** language) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get default language"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get default language DONE"); return ret; } @@ -303,17 +241,9 @@ int vc_setting_set_language(const char* language) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set default language"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_set_default_language(language); if (0 != ret) { @@ -338,7 +268,7 @@ int vc_setting_set_language(const char* language) } } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set default language DONE"); return ret; } @@ -347,15 +277,10 @@ int vc_setting_set_auto_language(bool value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set auto voice"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); if (value != true && value != false) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Invalid value"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -366,7 +291,7 @@ int vc_setting_set_auto_language(bool value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Set auto language (%s)", value ? "on" : "off"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set auto voice DONE"); return ret; } @@ -375,17 +300,9 @@ int vc_setting_get_auto_language(bool* value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get auto language"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == value) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == value, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_auto_language(value); if (0 != ret) { @@ -394,7 +311,7 @@ int vc_setting_get_auto_language(bool* value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get auto language (%s)", *value ? "true" : "false"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get auto language DONE"); return VC_ERROR_NONE; } @@ -403,15 +320,10 @@ int vc_setting_set_enabled(bool value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); if (value != true && value != false) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Invalid value"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -422,7 +334,7 @@ int vc_setting_set_enabled(bool value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Set service enabled (%s)", value ? "on" : "off"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled DONE"); return ret; } @@ -431,17 +343,9 @@ int vc_setting_get_enabled(bool* value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get service enabled"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == value) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == value, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_enabled(value); if (0 != ret) { @@ -451,7 +355,7 @@ int vc_setting_get_enabled(bool* value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get service enabled (%s)", *value ? "on" : "off"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get service enabled DONE"); return ret; } @@ -460,22 +364,14 @@ int vc_setting_set_enabled_changed_cb(vc_setting_enabled_changed_cb callback, vo { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); g_enabled_changed_cb = callback; g_enabled_changed_user_data = user_data; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled callback DONE"); return VC_ERROR_NONE; } @@ -484,16 +380,12 @@ int vc_setting_unset_enabled_changed_cb() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset service enabled callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); g_enabled_changed_cb = NULL; g_enabled_changed_user_data = NULL; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset service enabled callback DONE"); return VC_ERROR_NONE; } @@ -502,22 +394,14 @@ int vc_setting_set_current_language_changed_cb(vc_setting_current_language_chang { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set current language changed callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); g_current_language_changed_cb = callback; g_current_language_changed_user_data = user_data; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set current language changed callback DONE"); return VC_ERROR_NONE; } @@ -526,16 +410,12 @@ int vc_setting_unset_current_language_changed_cb() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset current language changed callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); g_current_language_changed_cb = NULL; g_current_language_changed_user_data = NULL; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset current language changed callback"); return VC_ERROR_NONE; } @@ -544,15 +424,12 @@ int vc_setting_set_engine_changed_cb(vc_setting_engine_changed_cb callback, void { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set engine changed callback"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Input param is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); g_engine_changed_cb = callback; g_engine_changed_user_data = user_data; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set engine changed callback DONE"); return VC_ERROR_NONE; } @@ -560,15 +437,11 @@ int vc_setting_unset_engine_changed_cb() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset engine changed callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); g_engine_changed_cb = NULL; g_engine_changed_user_data = NULL; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset engine changed callback DONE"); return VC_ERROR_NONE; } diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index 091a57c..dbe49de 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -71,7 +71,6 @@ static void __notify_cb(void *user_data, bundle *msg) } else { SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget get hello : invalid pid "); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_METHOD_HELLO */ else if (0 == strncmp(VCD_WIDGET_METHOD_SET_SERVICE_STATE, method, strlen(VCD_WIDGET_METHOD_SET_SERVICE_STATE))) { @@ -105,15 +104,12 @@ static void __notify_cb(void *user_data, bundle *msg) } else { SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget show tooltip : invalid pid"); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_WIDGET_METHOD_SHOW_TOOLTIP */ else if (0 == strncmp(VCD_WIDGET_METHOD_RESULT, method, strlen(VCD_WIDGET_METHOD_RESULT))) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Get widget result"); __vc_widget_cb_result(); - - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_WIDGET_METHOD_RESULT */ else if (0 == strncmp(VCD_WIDGET_METHOD_ERROR, method, strlen(VCD_WIDGET_METHOD_ERROR))) { @@ -137,13 +133,13 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get error message : reason(%d), daemon_pid(%d), msg(%s)", reason, daemon_pid, err_msg); __vc_widget_cb_error(reason, daemon_pid, err_msg); - - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_WIDGET_METHOD_ERROR */ else { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid msg"); } + + SLOG(LOG_DEBUG, TAG_VCW, "@@@ __notify_cb DONE"); } static void __on_connected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) diff --git a/server/vcd_server.c b/server/vcd_server.c index 3939f9c..8a21bcd 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -74,7 +74,7 @@ static Eina_Bool __stop_by_silence(void *data) vcd_server_mgr_stop(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Silence Detected DONE"); return EINA_FALSE; } @@ -84,7 +84,7 @@ static Eina_Bool __cancel_by_interrupt(void *data) vcd_server_mgr_cancel(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by interrupt DONE"); return EINA_FALSE; } @@ -94,7 +94,7 @@ static void __cancel_by_error(void *data) vcd_server_mgr_cancel(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by error DONE"); return; } @@ -121,7 +121,6 @@ static Eina_Bool __restart_engine(void *data) SLOG(LOG_INFO, TAG_VCD, "[Server Success] Restart recognition"); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); return EINA_FALSE; } @@ -191,7 +190,7 @@ void __server_recorder_interrupt_callback() ecore_timer_add(0, __cancel_by_interrupt, NULL); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by sound interrupt DONE"); } static void __config_lang_changed_cb(const char* current_lang, void* user_data) @@ -211,7 +210,7 @@ static void __config_lang_changed_cb(const char* current_lang, void* user_data) SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set language of engine : %d", ret); } - SLOG(LOG_INFO, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ Change language DONE"); return; } @@ -231,7 +230,7 @@ static void __config_foreground_changed_cb(int previous, int current, void* user } } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Change foreground DONE"); return; } diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index ac18b4b..967ad20 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -351,7 +351,7 @@ static void __vc_terminate_cb(rpc_port_stub_vcd_stub_vc_context_h context, void } tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC FINALIZE DONE"); pthread_mutex_unlock(&g_client_tidl_info_mutex); @@ -870,8 +870,6 @@ static void __vc_mgr_terminate_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h co } mgr_tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); @@ -942,12 +940,12 @@ static void __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h __request_tidl_connect(VCD_CLIENT_TYPE_MANAGER, pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC MANAGER REGISTER CALLBACK DONE"); } static int __vc_mgr_initialize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int audio_streaming_mode, int *service_state, int *foreground, int *daemon_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Initialize"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Initialize : pid(%d) service state(%d) foreground(%d) daemon_pid(%d)", pid, *service_state, *foreground, *daemon_pid); int ret = -1; @@ -962,14 +960,12 @@ static int __vc_mgr_initialize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h c *daemon_pid = getpid(); SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr initialize : pid(%d) service state(%d) foreground(%d) daemon_pid(%d)", pid, *service_state, *foreground, *daemon_pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); return ret; } static int __vc_mgr_finalize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Finalize"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr finalize : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Finalize : pid(%d)", pid); int ret = -1; @@ -978,15 +974,14 @@ static int __vc_mgr_finalize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h con SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr finalize : pid(%d)", pid); return ret; } static int __vc_mgr_set_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Set command"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set command : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Set command : pid(%d)", pid); int ret = -1; @@ -996,15 +991,14 @@ static int __vc_mgr_set_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set command : pid(%d)", pid); return ret; } static int __vc_mgr_unset_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager unset command"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr unset command : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager unset command : pid(%d)", pid); int ret = -1; @@ -1014,15 +1008,14 @@ static int __vc_mgr_unset_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_ return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr unset command : pid(%d)", pid); return ret; } static int __vc_mgr_set_demandable_client_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Set demandable client"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set demandable client : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Set demandable client : pid(%d)", pid); int ret = -1; @@ -1032,15 +1025,14 @@ static int __vc_mgr_set_demandable_client_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_ return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set demandable client : pid(%d)", pid); return ret; } static int __vc_mgr_set_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *audio_type, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set audio type"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d), audio type(%s)", pid, audio_type); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set audio type : pid(%d), audio type(%s)", pid, audio_type); int ret = -1; @@ -1050,15 +1042,14 @@ static int __vc_mgr_set_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d), audio type(%s)", pid, audio_type); return ret; } static int __vc_mgr_get_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, char **audio_type, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager get audio type"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager get audio type : pid(%d)", pid); int ret = -1; char* tmp_audio_type = NULL; @@ -1073,15 +1064,14 @@ static int __vc_mgr_get_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context *audio_type = strdup(tmp_audio_type); free(tmp_audio_type); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d)", pid); return ret; } static void __vc_mgr_set_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *key, const char *data, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set private data"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set domain : pid(%d), key(%s), data(%s)", pid, key, data); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set private data : pid(%d), key(%s), data(%s)", pid, key, data); int ret = -1; @@ -1091,13 +1081,12 @@ static void __vc_mgr_set_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_cont SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set private data : pid(%d), key(%s), data(%s)", pid, key, data); } static int __vc_mgr_get_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *key, char **data, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager get private data"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr get private data : pid(%d), key(%s)", pid, key); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager get private data : pid(%d), key(%s)", pid, key); int ret = -1; char *temp_data = NULL; @@ -1115,15 +1104,14 @@ static int __vc_mgr_get_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_conte *data = strdup(temp_data); free(temp_data); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr get private data : pid(%d), key(%s)", pid, key); return ret; } static int __vc_mgr_set_client_info_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set client info"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set client info : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set client info : pid(%d)", pid); int ret = -1; @@ -1133,15 +1121,14 @@ static int __vc_mgr_set_client_info_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_contex return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set client info : pid(%d)", pid); return ret; } static int __vc_mgr_set_domain_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *domain, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set domain type"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set domain : pid(%d), domain(%s)", pid, domain); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set domain type : pid(%d), domain(%s)", pid, domain); int ret = -1; @@ -1151,15 +1138,14 @@ static int __vc_mgr_set_domain_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h c return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set domain : pid(%d), domain(%s)", pid, domain); return ret; } static void __vc_mgr_do_action_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int type, const char *send_event, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager request to do action"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr request to do action : pid(%d), type(%d) send_event(%s)", pid, type, send_event); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager request to do action : pid(%d), type(%d) send_event(%s)", pid, type, send_event); int ret = -1; @@ -1168,7 +1154,7 @@ static void __vc_mgr_do_action_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h c SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr request to do action : pid(%d), type(%d) send_event(%s)", pid, type, send_event); } static int __vc_mgr_start_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int recognition_mode, bool exclusive_command_option, bool start_by_client, int disabled_cmd_type, void *user_data) @@ -1187,15 +1173,14 @@ static int __vc_mgr_start_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h contex return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager start DONE"); return ret; } static int __vc_mgr_stop_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager stop"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr stop : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager stop : pid(%d)", pid); int ret = -1; @@ -1206,15 +1191,14 @@ static int __vc_mgr_stop_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr stop : pid(%d)", pid); return ret; } static int __vc_mgr_cancel_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager cancel"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr cancel : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager cancel : pid(%d)", pid); int ret = -1; @@ -1224,24 +1208,23 @@ static int __vc_mgr_cancel_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h conte return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr cancel : pid(%d)", pid); return ret; } static void __vc_mgr_set_audio_streaming_mode_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int mode, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set audio streaming mode"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio streaming mode : pid(%d) mode(%d)", pid, mode); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set audio streaming mode : pid(%d) mode(%d)", pid, mode); vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)mode); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio streaming mode : pid(%d) mode(%d)", pid, mode); } static void __vc_mgr_send_specific_engine_request_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *engine_app_id, const char *event, const char *request, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager specific engine request"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager specific engine request"); int ret = -1; gsize decodingSize = 0; @@ -1257,23 +1240,21 @@ static void __vc_mgr_send_specific_engine_request_cb(rpc_port_stub_vcd_mgr_stub g_free(gDecodedRequest); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager specific engine request DONE"); } static void __vc_mgr_send_result_selection_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager result selection"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr result selection : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager result selection : pid(%d)", pid); vcd_server_mgr_result_select(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr result selection : pid(%d)", pid); } static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int utt_id, int utt_status, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send utterance status"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); pthread_mutex_lock(&g_client_tidl_info_mutex); @@ -1321,12 +1302,12 @@ static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr bundle_free(msg); pthread_mutex_unlock(&g_client_tidl_info_mutex); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); } static void __vc_mgr_send_audio_streaming_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int event, rpc_port_stub_vcd_mgr_stub_array_char_h data, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send audio streaming"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager send audio streaming"); char* buffer = NULL; int len = 0; @@ -1340,7 +1321,7 @@ static void __vc_mgr_send_audio_streaming_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_ SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager send audio streaming DONE"); } int __mgr_tidl_open_connection() @@ -1485,8 +1466,6 @@ static void __vc_widget_terminate_cb(rpc_port_stub_vcd_widget_stub_vc_widget_con } widget_tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); char *sender = NULL; @@ -1551,7 +1530,7 @@ static void __vc_widget_register_cb_cb(rpc_port_stub_vcd_widget_stub_vc_widget_ __request_tidl_connect(VCD_CLIENT_TYPE_WIDGET, pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC WIDGET REGISTER CALLBACK DONE"); } static int __vc_widget_initialize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int *service_state, int *daemon_pid, void *user_data) @@ -1572,14 +1551,12 @@ static int __vc_widget_initialize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_co *daemon_pid = getpid(); SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget initialize : pid(%d) service state(%d) daemon_pid(%d)", pid, *service_state, *daemon_pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); return ret; } static int __vc_widget_finalize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Finalize"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Finalize : pid(%d)", pid); int ret = -1; @@ -1589,15 +1566,14 @@ static int __vc_widget_finalize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_cont return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); return ret; } static int __vc_widget_start_recording_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int command, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Start Recording"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start recording : pid(%d) command(%d)", pid, command); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Start Recording : pid(%d) command(%d)", pid, command); int ret = -1; @@ -1607,15 +1583,14 @@ static int __vc_widget_start_recording_cb(rpc_port_stub_vcd_widget_stub_vc_widge return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start recording : pid(%d) command(%d)", pid, command); return ret; } static int __vc_widget_start_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int silence, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Start"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start : pid(%d) silence(%d)", pid, silence); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Start : pid(%d) silence(%d)", pid, silence); int ret = -1; @@ -1625,15 +1600,14 @@ static int __vc_widget_start_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_ return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start : pid(%d) silence(%d)", pid, silence); return ret; } static int __vc_widget_stop_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Stop"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget stop : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Stop : pid(%d)", pid); int ret = -1; @@ -1643,15 +1617,14 @@ static int __vc_widget_stop_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget stop : pid(%d)", pid); return ret; } static int __vc_widget_cancel_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Cancel"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Cancel : pid(%d)", pid); int ret = -1; @@ -1661,15 +1634,14 @@ static int __vc_widget_cancel_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); return ret; } static int __vc_widget_enable_asr_result_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int enable, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Enable Asr Result"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget enable asr result : pid(%d) enable(%d)", pid, enable); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Enable Asr Result : pid(%d) enable(%d)", pid, enable); int ret = -1; @@ -1679,15 +1651,14 @@ static int __vc_widget_enable_asr_result_cb(rpc_port_stub_vcd_widget_stub_vc_wid return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget enable asr result : pid(%d) enable(%d)", pid, enable); return ret; } static void __vc_widget_set_foreground_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int value, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Set Foreground"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget set foreground : pid(%d) value(%d)", pid, value); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Set Foreground : pid(%d) value(%d)", pid, value); int ret = -1; @@ -1700,7 +1671,7 @@ static void __vc_widget_set_foreground_cb(rpc_port_stub_vcd_widget_stub_vc_widge SLOG(LOG_DEBUG, TAG_VCD, "@@@ send request set foreground to manager"); vcdc_send_request_set_foreground(pid, value); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget set foreground : pid(%d) value(%d)", pid, value); return; } @@ -1791,8 +1762,6 @@ static void __vc_setting_terminate_cb(rpc_port_stub_vcd_setting_stub_vc_setting_ } setting_tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - pthread_mutex_unlock(&g_setting_tidl_info_mutex); } rpc_port_stub_vcd_setting_stub_vc_setting_context_set_tag(context, NULL); -- 2.7.4 From 0b2b2a9a540cd7870a3724ed5569cd62563630ca Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 6 Jul 2022 16:11:34 +0900 Subject: [PATCH 11/16] Replace codes to check feature and privilege Change-Id: I2691dbf7a1c3f4a5bcdb8e9eebb29b28cad050ce Signed-off-by: sooyeon --- client/vc.c | 388 ++++++++++--------------- client/vc_mgr.c | 882 +++++++++++++++++++------------------------------------- server/vce.c | 110 +++---- 3 files changed, 505 insertions(+), 875 deletions(-) diff --git a/client/vc.c b/client/vc.c index 07234ba..c61a3f0 100644 --- a/client/vc.c +++ b/client/vc.c @@ -208,6 +208,18 @@ static int __vc_check_privilege() return VC_ERROR_NONE; } +int __check_feature_privilege() +{ + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE + } + + return VC_ERROR_NONE; +} + //LCOV_EXCL_START static const char* __vc_get_error_code(vc_error_e err) { @@ -349,12 +361,10 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) int vc_initialize(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Initialize"); @@ -379,7 +389,7 @@ int vc_initialize(void) return VC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } - int ret = vc_config_mgr_initialize(g_vc->handle); + ret = vc_config_mgr_initialize(g_vc->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to init config manager : %s", __vc_get_error_code(__vc_convert_config_error_code(ret))); //LCOV_EXCL_LINE @@ -439,13 +449,9 @@ static void __vc_internal_unprepare(void) int vc_deinitialize(void) { int ret = VC_ERROR_NONE; - - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Deinitialize"); @@ -671,12 +677,10 @@ static void __end_prepare_thread(void *data, Ecore_Thread *thread) int vc_prepare(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); @@ -698,12 +702,10 @@ int vc_prepare(void) //LCOV_EXCL_START int vc_prepare_sync(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); @@ -729,12 +731,10 @@ int vc_prepare_sync(void) int vc_unprepare(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unprepare"); @@ -759,12 +759,10 @@ int vc_unprepare(void) int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -776,8 +774,6 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language"); - - int ret = -1; ret = vc_config_mgr_get_language_list(callback, user_data); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -792,12 +788,10 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user int vc_get_current_language(char** language) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -810,7 +804,6 @@ int vc_get_current_language(char** language) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); - int ret = -1; ret = vc_config_mgr_get_default_language(language); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -824,12 +817,10 @@ int vc_get_current_language(char** language) int vc_get_state(vc_state_e* state) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -860,12 +851,10 @@ int vc_get_state(vc_state_e* state) int vc_get_service_state(vc_service_state_e* state) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -906,12 +895,10 @@ int vc_get_service_state(vc_service_state_e* state) int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == vc_sys_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); *vc_sys_cmd_list = NULL; @@ -935,7 +922,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) bool is_sys_cmd_valid = false; int count = 0; - int ret = -1; + ret = -1; bool is_prepared = false; do { ret = vc_tidl_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid); @@ -1021,12 +1008,10 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) */ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Is command format supported"); @@ -1154,12 +1139,10 @@ void __set_command(vc_h vc, vc_cmd_type_e type) int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -1185,7 +1168,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) list = (vc_cmd_list_s*)vc_cmd_list; RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Invalid command list"); - int ret = 0; + ret = 0; char* invocation_name = NULL; if (VC_COMMAND_TYPE_BACKGROUND == type) { ret = __vc_get_invocation_name(&invocation_name); @@ -1218,12 +1201,10 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) int vc_unset_command_list(int type) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1238,7 +1219,7 @@ int vc_unset_command_list(int type) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list"); int count = 0; - int ret = -1; + ret = -1; bool is_prepared = false; while (0 != ret) { ret = vc_tidl_request_unset_command(g_vc->handle, (vc_cmd_type_e)type); @@ -1280,12 +1261,10 @@ int vc_unset_command_list(int type) //LCOV_EXCL_START int vc_set_command_list_from_file(const char* file_path, int type) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1305,7 +1284,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file"); - int ret = 0; + ret = 0; char* invocation_name = NULL; if (VC_COMMAND_TYPE_BACKGROUND == type) { ret = __vc_get_invocation_name(&invocation_name); @@ -1740,12 +1719,10 @@ void __vc_cb_result(void) int vc_get_result(vc_result_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1770,7 +1747,7 @@ int vc_get_result(vc_result_cb callback, void* user_data) return VC_ERROR_INVALID_PARAMETER; } - int ret = vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); + ret = vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); if (0 != ret || NULL == temp_text) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get result, ret(%d) temp_text(%s)", ret, temp_text); //LCOV_EXCL_LINE return ret; @@ -1797,12 +1774,10 @@ int vc_get_result(vc_result_cb callback, void* user_data) int vc_set_result_cb(vc_result_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); @@ -1822,12 +1797,10 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) int vc_unset_result_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1889,12 +1862,10 @@ int __vc_cb_manager_pid(int manager_pid) int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client service state changed callback is NULL"); @@ -1914,12 +1885,10 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* int vc_unset_service_state_changed_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1937,12 +1906,10 @@ int vc_unset_service_state_changed_cb(void) int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client state changed callback is NULL"); @@ -1962,12 +1929,10 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) int vc_unset_state_changed_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1985,12 +1950,10 @@ int vc_unset_state_changed_cb(void) int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client current language changed callback is NULL"); @@ -2010,12 +1973,10 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, int vc_unset_current_language_changed_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2033,12 +1994,10 @@ int vc_unset_current_language_changed_cb(void) int vc_set_error_cb(vc_error_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client error callback is NULL"); @@ -2058,12 +2017,10 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) int vc_unset_error_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2081,17 +2038,15 @@ int vc_unset_error_cb(void) int vc_set_invocation_name(const char* name) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set invocation name"); - int ret = vc_client_get_client_state(g_vc, &state); + ret = vc_client_get_client_state(g_vc, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return ret; @@ -2112,13 +2067,9 @@ int vc_set_server_dialog(const char* app_id, const char* credential) { vc_state_e state; int ret = -1; - - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == credential, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Credential is NULL"); @@ -2192,12 +2143,9 @@ int vc_unset_server_dialog(const char* app_id) int ret = -1; char* tmp_appid = NULL; - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2266,13 +2214,10 @@ int vc_unset_server_dialog(const char* app_id) int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start) { vc_state_e state; - - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2288,7 +2233,7 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start); - int ret = vc_tidl_request_request_dialog(getpid(), disp_text, utt_text, auto_start); + ret = vc_tidl_request_request_dialog(getpid(), disp_text, utt_text, auto_start); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request dialog, ret(%d)", ret); return VC_ERROR_OPERATION_FAILED; @@ -2797,12 +2742,9 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request tts"); - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2858,12 +2800,9 @@ int vc_tts_cancel(int utt_id) SLOG(LOG_DEBUG, TAG_VCC, "@@@ Cancel tts"); - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2924,12 +2863,9 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get tts audio format"); - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2979,12 +2915,10 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -3005,12 +2939,10 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) int vc_tts_unset_streaming_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3044,12 +2976,10 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); @@ -3069,12 +2999,10 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us int vc_tts_unset_utterance_status_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 813ee44..e07325f 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -273,11 +273,8 @@ static int __vc_mgr_check_privilege() return VC_ERROR_NONE; } -int vc_mgr_initialize(void) +int __check_mgr_feature_privilege() { - SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Initialize"); - - if (0 != __vc_mgr_get_feature_enabled()) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); return VC_ERROR_NOT_SUPPORTED; @@ -287,6 +284,18 @@ int vc_mgr_initialize(void) return VC_ERROR_PERMISSION_DENIED; } + return VC_ERROR_NONE; +} + +int vc_mgr_initialize(void) +{ + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Initialize"); + + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; + /* check handle */ if (true == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Already initialized"); @@ -303,7 +312,7 @@ int vc_mgr_initialize(void) return VC_ERROR_OUT_OF_MEMORY; } - int ret = vc_config_mgr_initialize(g_vc_m->handle + VC_MANAGER_CONFIG_HANDLE); + ret = vc_config_mgr_initialize(g_vc_m->handle + VC_MANAGER_CONFIG_HANDLE); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to init config manager : %d", ret); vc_mgr_client_destroy(g_vc_m); @@ -354,14 +363,10 @@ int vc_mgr_deinitialize(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Deinitialize"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (false == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NOT initialized"); @@ -403,12 +408,12 @@ int vc_mgr_deinitialize(void) int cnt = VC_COMMAND_TYPE_FOREGROUND; do { - int ret = vc_cmd_parser_delete_file(getpid(), cnt); + ret = vc_cmd_parser_delete_file(getpid(), cnt); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to delete file, type(%d), ret(%d)", cnt, ret); } while (VC_COMMAND_TYPE_EXCLUSIVE >= ++cnt); - int ret = vc_db_finalize(); + ret = vc_db_finalize(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to finalize DB, ret(%d)", ret); } @@ -565,14 +570,10 @@ int vc_mgr_prepare(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Prepare"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -602,14 +603,10 @@ int vc_mgr_unprepare(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unprepare"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -634,14 +631,10 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Foreach Supported Language"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -651,7 +644,6 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* return VC_ERROR_INVALID_STATE; } - int ret = -1; ret = vc_config_mgr_get_language_list(callback, user_data); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -665,14 +657,10 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* int vc_mgr_get_current_language(char** language) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -682,7 +670,6 @@ int vc_mgr_get_current_language(char** language) return VC_ERROR_INVALID_STATE; } - int ret = -1; ret = vc_config_mgr_get_default_language(language); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -698,14 +685,10 @@ int vc_mgr_get_state(vc_state_e* state) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get State"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -735,14 +718,10 @@ int vc_mgr_get_service_state(vc_service_state_e* state) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get Service State"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -781,14 +760,10 @@ int vc_mgr_set_demandable_client_rule(const char* rule) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Set Demandable client rule(%s)", rule); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -799,7 +774,6 @@ int vc_mgr_set_demandable_client_rule(const char* rule) /* check state */ RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); - int ret = -1; ret = vc_info_parser_set_demandable_client(rule); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] rule is NOT valid"); @@ -821,18 +795,14 @@ int vc_mgr_unset_demandable_client_rule(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Unset Demandable client"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_info_parser_set_demandable_client(NULL); - int ret = vc_mgr_tidl_request_demandable_client(g_vc_m->handle); + ret = vc_mgr_tidl_request_demandable_client(g_vc_m->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request unset client rule to daemon : %s", __vc_mgr_get_error_code(ret)); } @@ -845,14 +815,10 @@ int vc_mgr_is_command_format_supported(int format, bool* support) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Is command type supported"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == support, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -888,14 +854,10 @@ int vc_mgr_enable_command_type(int cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Enable Command Type, cmd_type(%d)", cmd_type); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_COMMAND_TYPE_FOREGROUND > cmd_type || VC_COMMAND_TYPE_EXCLUSIVE < cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] cmd_type is not valid. (%d)", cmd_type); @@ -916,8 +878,6 @@ int vc_mgr_enable_command_type(int cmd_type) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret; - ret = vc_mgr_client_enable_command_type(g_vc_m, (vc_cmd_type_e)cmd_type); // enable the cmd type if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to enable the command type(%d). ret(%d)", cmd_type, ret); @@ -934,14 +894,10 @@ int vc_mgr_disable_command_type(int cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Disable Command Type, cmd_type(%d)", cmd_type); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_COMMAND_TYPE_FOREGROUND > cmd_type || VC_COMMAND_TYPE_EXCLUSIVE < cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] cmd type is not valid, (%d)", cmd_type); @@ -962,8 +918,6 @@ int vc_mgr_disable_command_type(int cmd_type) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret; - ret = vc_mgr_client_disable_command_type(g_vc_m, (vc_cmd_type_e)cmd_type); // enable the cmd type if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to disable the command type(%d). ret(%d)", cmd_type, ret); @@ -980,14 +934,10 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1012,7 +962,6 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input command list"); int i; - int ret; bool success_save = false; for (i = VC_COMMAND_TYPE_FOREGROUND; i <= VC_COMMAND_TYPE_EXCLUSIVE; i++) { ret = vc_cmd_parser_delete_file(getpid(), i); @@ -1047,14 +996,10 @@ int vc_mgr_unset_command_list(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unset Command list"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1065,8 +1010,6 @@ int vc_mgr_unset_command_list(void) /* check state */ RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - - int ret = -1; ret = vc_mgr_tidl_request_unset_command(g_vc_m->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request unset command to daemon : %s", __vc_mgr_get_error_code(ret)); @@ -1089,14 +1032,10 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list from file, type(%d)", type); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); @@ -1121,7 +1060,7 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = vc_cmd_parser_delete_file(getpid(), type); + ret = vc_cmd_parser_delete_file(getpid(), type); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to delete file, type(4), ret(%d)", ret); @@ -1144,14 +1083,10 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set preloaded command list"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); @@ -1171,7 +1106,7 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); /* Only support to set background commands for preloaded application */ - int ret = vc_json_set_commands_from_file(file_path, VC_COMMAND_TYPE_BACKGROUND, NULL); + ret = vc_json_set_commands_from_file(file_path, VC_COMMAND_TYPE_BACKGROUND, NULL); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to insert preloaded commands into db"); @@ -1183,14 +1118,10 @@ int vc_mgr_set_audio_type(const char* audio_id) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set audio type, audio_id(%s)", audio_id); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (NULL == audio_id || !strncmp(audio_id, "", strlen(audio_id))) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -1211,7 +1142,6 @@ int vc_mgr_set_audio_type(const char* audio_id) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; /* Request */ ret = vc_mgr_tidl_request_set_audio_type(g_vc_m->handle, audio_id); if (0 != ret) { @@ -1231,14 +1161,10 @@ int vc_mgr_get_audio_type(char** audio_id) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Get audio type"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == audio_id, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1262,7 +1188,7 @@ int vc_mgr_get_audio_type(char** audio_id) if (NULL == temp) { /* Not initiallized */ - int ret = -1; + ret = -1; while (0 != ret) { ret = vc_mgr_tidl_request_get_audio_type(g_vc_m->handle, &temp); if (0 != ret) { @@ -1289,14 +1215,10 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Foreach current commands"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1324,7 +1246,6 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) int fg_pid = 0; int mgr_pid = 0; - int ret = -1; /* Get foreground pid */ if (0 != vc_mgr_client_get_foreground(g_vc_m, &fg_pid)) { @@ -1463,14 +1384,10 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Set recognition mode = %d", mode); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; /* check vc recognition mode */ if (mode < VC_RECOGNITION_MODE_STOP_BY_SILENCE || mode > VC_RECOGNITION_MODE_MANUAL) { @@ -1498,16 +1415,10 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } - - int ret = -1; + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == mode, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter, mode is NULL ptr"); @@ -1531,14 +1442,10 @@ int vc_mgr_set_private_data(const char* key, const char* data) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Set private data"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == key, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1556,7 +1463,6 @@ int vc_mgr_set_private_data(const char* key, const char* data) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; ret = vc_mgr_tidl_request_set_private_data(g_vc_m->handle, key, data); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set private data : %s", __vc_mgr_get_error_code(ret)); @@ -1574,14 +1480,10 @@ int vc_mgr_get_private_data(const char* key, char** data) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get private data"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (NULL == key || NULL == data) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1602,10 +1504,7 @@ int vc_mgr_get_private_data(const char* key, char** data) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; char* temp = NULL; - - ret = vc_mgr_tidl_request_get_private_data(g_vc_m->handle, key, &temp); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get private data request : %s", __vc_mgr_get_error_code(ret)); @@ -1613,7 +1512,6 @@ int vc_mgr_get_private_data(const char* key, char** data) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Get private data, key(%s), data(%s)", key, temp); } - if (NULL != temp) { *data = strdup(temp); free(temp); @@ -1630,14 +1528,10 @@ int vc_mgr_set_domain(const char* domain) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set domain"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == domain, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1655,8 +1549,6 @@ int vc_mgr_set_domain(const char* domain) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; - ret = vc_mgr_tidl_request_set_domain(g_vc_m->handle, domain); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set domain request : %s", __vc_mgr_get_error_code(ret)); @@ -1673,14 +1565,10 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] do action"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (type < VC_SEND_EVENT_TYPE_TEXT || VC_SEND_EVENT_TYPE_HAPTIC_EVENT < type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] send event type is not valid, (%d)", type); @@ -1703,7 +1591,6 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; ret = vc_mgr_tidl_request_do_action(g_vc_m->handle, type, send_event); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to do action request : %s", __vc_mgr_get_error_code(ret)); @@ -1720,14 +1607,10 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] send specific engine request"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] specific engine request. engine app id(%s), event(%s), request(%s)", engine_app_id, event, request); @@ -1754,7 +1637,6 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; ret = vc_mgr_tidl_send_specific_engine_request(g_vc_m->handle, engine_app_id, event, request); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to specific engine request : %s", __vc_mgr_get_error_code(ret)); @@ -1771,14 +1653,10 @@ int vc_mgr_start(bool exclusive_command_option) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request start"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1814,7 +1692,6 @@ int vc_mgr_start(bool exclusive_command_option) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get disabled command type"); } - int ret; vc_recognition_mode_e recognition_mode = VC_RECOGNITION_MODE_STOP_BY_SILENCE; if (0 != vc_mgr_get_recognition_mode(&recognition_mode)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get recognition mode"); @@ -1844,14 +1721,10 @@ int vc_mgr_stop(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request stop"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1881,7 +1754,7 @@ int vc_mgr_stop(void) return VC_ERROR_IN_PROGRESS_TO_READY; } - int ret = -1; + ret = -1; /* do request */ vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STOPPING); ret = vc_mgr_tidl_request_stop(g_vc_m->handle); @@ -1901,14 +1774,10 @@ int vc_mgr_cancel(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Request cancel"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1937,7 +1806,7 @@ int vc_mgr_cancel(void) return VC_ERROR_IN_PROGRESS_TO_READY; } - int ret = -1; + ret = -1; vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_CANCELING); ret = vc_mgr_tidl_request_cancel(g_vc_m->handle); if (0 != ret) { @@ -1996,14 +1865,10 @@ int __vc_mgr_set_volume(float volume) int vc_mgr_get_recording_volume(float* volume) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == volume, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2060,14 +1925,10 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Select result"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; /* Do not check state for 'restart continuously' mode */ @@ -2098,7 +1959,6 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) } /* Request */ - int ret = -1; ret = vc_mgr_tidl_send_result_selection(g_vc_m->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to send result selection : %s", __vc_mgr_get_error_code(ret)); @@ -2321,14 +2181,10 @@ void __vc_mgr_cb_speech_detected() int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2350,14 +2206,10 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) int vc_mgr_unset_all_result_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2375,14 +2227,10 @@ int vc_mgr_unset_all_result_cb(void) int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2402,14 +2250,10 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) int vc_mgr_unset_result_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2427,14 +2271,10 @@ int vc_mgr_unset_result_cb(void) int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2454,14 +2294,10 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) int vc_mgr_unset_pre_result_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2481,14 +2317,10 @@ int vc_mgr_get_error_message(char** err_msg) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get error message"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; /* check state */ vc_state_e state; @@ -2504,7 +2336,6 @@ int vc_mgr_get_error_message(char** err_msg) return VC_ERROR_OPERATION_FAILED; } - int ret; ret = vc_mgr_client_get_error_message(g_vc_m, err_msg); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get error message"); @@ -2607,14 +2438,10 @@ static Eina_Bool __vc_mgr_notify_state_changed(void *data) int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -2636,14 +2463,10 @@ int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) int vc_mgr_unset_state_changed_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2708,14 +2531,10 @@ int __vc_mgr_cb_service_state(int state) int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -2737,14 +2556,10 @@ int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, vo int vc_mgr_unset_service_state_changed_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2761,14 +2576,10 @@ int vc_mgr_unset_service_state_changed_cb(void) int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -2790,14 +2601,10 @@ int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void int vc_mgr_unset_speech_detected_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2814,14 +2621,10 @@ int vc_mgr_unset_speech_detected_cb(void) int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2842,14 +2645,10 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba int vc_mgr_unset_current_language_changed_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2867,14 +2666,10 @@ int vc_mgr_unset_current_language_changed_cb(void) int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2894,14 +2689,10 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) int vc_mgr_unset_error_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3054,14 +2845,10 @@ int __vc_mgr_cb_feedback_streaming(int pid, int utt_id, vc_feedback_event_e even int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3081,14 +2868,10 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d int vc_mgr_unset_dialog_request_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3106,14 +2889,10 @@ int vc_mgr_unset_dialog_request_cb(void) int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3133,14 +2912,10 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us int vc_mgr_unset_private_data_set_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3158,14 +2933,10 @@ int vc_mgr_unset_private_data_set_cb(void) int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3185,14 +2956,10 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba int vc_mgr_unset_private_data_requested_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3393,13 +3160,10 @@ int __vc_mgr_request_auth_cancel(int pid) int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3457,13 +3221,10 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] set feedback audio format"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3487,13 +3248,10 @@ int vc_mgr_unset_feedback_audio_format_cb() { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] unset feedback audio format"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3515,13 +3273,10 @@ int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] set feedback streaming"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3554,13 +3309,10 @@ int vc_mgr_unset_feedback_streaming_cb() { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] unset feedback streaming"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; pthread_mutex_lock(&g_feedback_streaming_cb_mutex); @@ -3591,14 +3343,10 @@ int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* us { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] set vc tts streaming callback"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3631,14 +3379,10 @@ int vc_mgr_unset_vc_tts_streaming_cb() { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] unset vc tts streaming callback"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; pthread_mutex_lock(&g_vc_tts_streaming_cb_mutex); @@ -3780,13 +3524,10 @@ int vc_mgr_start_feedback(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] start feedback"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Request start TTS feedback"); @@ -3820,13 +3561,10 @@ int vc_mgr_stop_feedback(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] stop feedback"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Request stop TTS feedback"); @@ -3840,7 +3578,7 @@ int vc_mgr_stop_feedback(void) RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state); #if 1 - int ret = -1; + ret = -1; while (1) { vc_feedback_data_s* feedback_data = NULL; @@ -3873,14 +3611,10 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] send utterance status, pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_TTS_UTTERANCE_NONE > utt_status || VC_TTS_UTTERANCE_CANCELED < utt_status || 0 == utt_status) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] utt_status is not valid. (%d)", utt_status); @@ -3901,7 +3635,7 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = vc_mgr_tidl_send_utterance_status(pid, utt_id, utt_status); + ret = vc_mgr_tidl_send_utterance_status(pid, utt_id, utt_status); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to send utterance status : %s", __vc_mgr_get_error_code(ret)); else @@ -3947,14 +3681,10 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* { SLOG(LOG_INFO, TAG_VCM, "[Manager] Send audio streaming to the engine service, event(%d)", event); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_AUDIO_STREAMING_EVENT_FAIL > event || VC_AUDIO_STREAMING_EVENT_FINISH < event || 0 == event) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] event is invalid parameter (%d)", event); @@ -3964,7 +3694,7 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* RETVM_IF(NULL == buffer, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state = VC_STATE_NONE; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; @@ -3999,14 +3729,10 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) { SLOG(LOG_INFO, TAG_VCM, "[Manager] Set multi assistant mode, mode(%d)", mode); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_AUDIO_STREAMING_MODE_VC_SERVICE > mode || VC_AUDIO_STREAMING_MODE_OUTSIDE < mode) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] mode is invalid parameter (%d)", mode); @@ -4014,7 +3740,7 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) } vc_state_e state = VC_STATE_NONE; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; @@ -4173,14 +3899,10 @@ int vc_mgr_change_system_volume(vc_system_volume_event_e event) { SLOG(LOG_INFO, TAG_VCM, "[Manager] Change system volume"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_NEARFIELD > event || VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_FARFIELD < event) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] event is invalid parameter (%d)", event); @@ -4188,7 +3910,7 @@ int vc_mgr_change_system_volume(vc_system_volume_event_e event) } vc_state_e state; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; @@ -4211,17 +3933,13 @@ int vc_mgr_recover_system_volume(void) { SLOG(LOG_INFO, TAG_VCM, "[Manager] recover system volume"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state = VC_STATE_NONE; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; diff --git a/server/vce.c b/server/vce.c index 7ea2327..1b4839f 100644 --- a/server/vce.c +++ b/server/vce.c @@ -172,7 +172,7 @@ static int __vce_check_privilege() return VCE_ERROR_NONE; } -int vce_main(int argc, char** argv, vce_request_callback_s *callback) +int __check_engine_feature_privilege() { if (0 != __vce_get_feature_enabled()) { return VCE_ERROR_NOT_SUPPORTED; @@ -181,11 +181,21 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) return VCE_ERROR_PERMISSION_DENIED; } + return VCE_ERROR_NONE; +} + +int vce_main(int argc, char** argv, vce_request_callback_s *callback) +{ + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; + SLOG(LOG_DEBUG, TAG_VCD, " "); SLOG(LOG_DEBUG, TAG_VCD, " "); SLOG(LOG_INFO, TAG_VCD, "===== VC Engine Service Initialize"); - int ret = VCE_ERROR_NONE; + ret = VCE_ERROR_NONE; if (!ecore_init()) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()"); @@ -373,14 +383,10 @@ int vce_get_command_count(vce_cmd_h vce_command, int* count) int vce_get_audio_type(char** audio_type) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; ret = vcd_get_audio_type(audio_type); if (0 != ret) { @@ -392,14 +398,10 @@ int vce_get_audio_type(char** audio_type) int vce_set_private_data(const char* key, const char* data) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == key || NULL == data) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); @@ -428,14 +430,10 @@ int vce_set_private_data(const char* key, const char* data) int vce_get_private_data(const char* key, char** data) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == key || NULL == data) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); @@ -452,14 +450,10 @@ int vce_get_private_data(const char* key, char** data) int vce_start_recording() { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; ret = vcd_start_recording(); if (0 != ret) { @@ -471,14 +465,10 @@ int vce_start_recording() int vce_stop_recording() { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; ret = vcd_stop_recording(); if (0 != ret) { @@ -490,14 +480,12 @@ int vce_stop_recording() int vce_send_update_status(vce_update_event_e update_event, const char* msg) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; - int ret = vcd_send_update_status(update_event, msg); + ret = vcd_send_update_status(update_event, msg); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send update status"); } @@ -507,19 +495,17 @@ int vce_send_update_status(vce_update_event_e update_event, const char* msg) int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == callback_func) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); return VCE_ERROR_INVALID_PARAMETER; } - int ret = vcd_set_private_data_set_cb(callback_func); + ret = vcd_set_private_data_set_cb(callback_func); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data set cb"); } @@ -529,19 +515,17 @@ int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func) int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_func) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == callback_func) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); return VCE_ERROR_INVALID_PARAMETER; } - int ret = vcd_set_private_data_requested_cb(callback_func); + ret = vcd_set_private_data_requested_cb(callback_func); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data requested cb"); } -- 2.7.4 From a0587234c44f725b11922ffc0afca5abfbbb4b08 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Fri, 29 Jul 2022 15:00:12 +0900 Subject: [PATCH 12/16] Fix svace and coverity issues Change-Id: Ic72a37bbbd082b9cbb35f8cafdf9384a6cbd60d6 Signed-off-by: sooyeon --- client/vc_mgr.c | 1 - client/vc_setting_tidl.c | 2 ++ client/vc_tidl.c | 2 ++ common/vc_info_parser.c | 1 - server/vcd_client_data.c | 1 - server/vcd_server.c | 6 +++--- server/vcd_tidl.c | 6 ++++++ 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index e07325f..3746242 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -34,7 +34,6 @@ #include "vc_mgr_tidl.h" #include "vc_mgr_data.h" #include "vc_mgr_player.h" -#include "voice_control.h" #include "voice_control_command.h" #include "voice_control_command_expand.h" #include "voice_control_common.h" diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index 314daf9..e2c8b10 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -73,6 +73,8 @@ static char* __get_engine_appid(void) SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + free(engine_name); + return appid; } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 33d91a5..2601636 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -82,6 +82,8 @@ static char* __get_engine_appid(void) SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + free(engine_name); + return appid; } diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 56ce84b..3e7ee27 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -25,7 +25,6 @@ #include "vc_info_parser.h" #include "vc_main.h" #include "voice_control_command.h" -#include "voice_control_command_expand.h" #include "voice_control_common.h" diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 057d919..6620180 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -22,7 +22,6 @@ #include "vcd_config.h" #include "vcd_main.h" -#include "voice_control_command_expand.h" /* Client list */ static GSList* g_client_list = NULL; diff --git a/server/vcd_server.c b/server/vcd_server.c index 8a21bcd..868a681 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1504,7 +1504,7 @@ static void __vcd_cleanup_client(vcd_client_type_e type) } if (0 == ret || mgr_pid > 0) { - SLOG(LOG_INFO, TAG_VCD, "@@@ Clean up %s client ", type ? (type == 1) ? "Widget" : "Manager" : "Normal"); + SLOG(LOG_INFO, TAG_VCD, "@@@ Clean up %s client ", type ? (type == VCD_CLIENT_TYPE_WIDGET) ? "Widget" : "Manager" : "Normal"); if (NULL != client_list && client_count > 0) { for (i = 0; i < client_count; i++) { exist = false; @@ -1513,7 +1513,7 @@ static void __vcd_cleanup_client(vcd_client_type_e type) iter = g_list_nth(g_proc_list, j); if (NULL != iter) { if (*(client_list + i) == GPOINTER_TO_INT(iter->data)) { - SLOG(LOG_INFO, TAG_VCD, "%s pid(%d) is running", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i)); + SLOG(LOG_INFO, TAG_VCD, "%s pid(%d) is running", type ? (type == VCD_CLIENT_TYPE_WIDGET) ? "Widget" : "Manager" : "Normal", *(client_list + i)); exist = true; break; } @@ -1521,7 +1521,7 @@ static void __vcd_cleanup_client(vcd_client_type_e type) } if (false == exist) { - SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i)); + SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == VCD_CLIENT_TYPE_WIDGET) ? "Widget" : "Manager" : "Normal", *(client_list + i)); if (VCD_CLIENT_TYPE_NORMAL == type) vcd_server_finalize(*(client_list + i)); else if (VCD_CLIENT_TYPE_WIDGET == type) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 967ad20..b7ed0b9 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -253,6 +253,8 @@ void __send_signal(bundle* msg, vcd_client_type_e type) } } } + + free(client_list); pthread_mutex_unlock(&g_client_tidl_info_mutex); } /* signal to clients */ else if (VCD_CLIENT_TYPE_WIDGET == type) { @@ -1921,6 +1923,8 @@ int vcdc_send_manager_pid(int manager_pid) ret = vcd_client_get_tidl_list(&client_list, &client_count); if (0 != ret || 0 == client_count) { SLOG(LOG_WARN, TAG_VCD, "[WARNING] There is no client"); + if (NULL != client_list) + free(client_list); return VCD_ERROR_NONE; } @@ -1958,6 +1962,8 @@ int vcdc_send_manager_pid(int manager_pid) bundle_free(msg); } + free(client_list); + return VCD_ERROR_NONE; } -- 2.7.4 From 764c272cc58ca9cb10e63502e7aa23010b6e691a Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 1 Aug 2022 10:46:42 +0900 Subject: [PATCH 13/16] Update version (1.70.5) Change-Id: Idc0ab244ddd26b049995da126cdee2c6e73deb62 Signed-off-by: sooyeon --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index daa639f..2142161 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.70.4) +SET(VERSION ${VERSION}) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index eff8088..415086c 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.70.4 +Version: 1.70.5 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From cf8bc6a6522c6d716c13127333647ef959c2d0c5 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 1 Aug 2022 15:11:23 +0900 Subject: [PATCH 14/16] Change type casting using intptr_t Change-Id: I596abafd51aa4af3e537b0df561b40c50cfcbc52 Signed-off-by: sooyeon --- server/vcd_tidl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index b7ed0b9..e4a7426 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -1383,7 +1383,8 @@ int __mgr_tidl_close_connection() */ static void __widget_on_connected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); + int pid = (intptr_t)user_data; + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); widget_tidl_info->connected = true; widget_tidl_info->connection_requesting = false; @@ -1393,7 +1394,8 @@ static void __widget_on_connected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h static void __widget_on_disconnected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); + int pid = (intptr_t)user_data; + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); widget_tidl_info->connected = false; widget_tidl_info->connection_requesting = false; @@ -1403,7 +1405,8 @@ static void __widget_on_disconnected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_ static void __widget_on_rejected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); + int pid = (intptr_t)user_data; + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); widget_tidl_info->connection_requesting = false; @@ -1420,7 +1423,8 @@ static rpc_port_proxy_vcd_widget_proxy_vcd_widget_h __widget_create_rpc_port(con }; rpc_port_proxy_vcd_widget_proxy_vcd_widget_h handle = NULL; - if (0 != rpc_port_proxy_vcd_widget_proxy_vcd_widget_create(engine_app_id, &rpc_callback, (void *)pid, &handle)) { + intptr_t ptr_pid = pid; + if (0 != rpc_port_proxy_vcd_widget_proxy_vcd_widget_create(engine_app_id, &rpc_callback, (void *)ptr_pid, &handle)) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); return NULL; } -- 2.7.4 From 9ed976933063155f80c7be99a864c8e72f56e0aa Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 1 Aug 2022 20:20:41 +0900 Subject: [PATCH 15/16] Fix tidl error handling codes Change-Id: I2d4662c41d486335b597d5f3930164150873f5d9 Signed-off-by: sooyeon --- client/vc_mgr_tidl.c | 100 +++++++++++++++++++++++++++----- client/vc_setting_tidl.c | 13 +++-- client/vc_tidl.c | 146 ++++++++++++++++++++++++++++++++++++----------- client/vc_widget_tidl.c | 58 ++++++++++++++++--- 4 files changed, 260 insertions(+), 57 deletions(-) diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index 18b7ac8..a6218ba 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -635,6 +635,15 @@ int vc_mgr_tidl_close_connection() return VC_ERROR_NONE; } +static int __convert_unhandled_error(int ret) +{ + if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { + return VC_ERROR_OPERATION_FAILED; + } + + return ret; +} + static void __request_tidl_connect() { if (g_proxy_tidl_info->connection_requesting) { @@ -755,7 +764,12 @@ int vc_mgr_tidl_request_initialize(int pid, int audio_streaming_mode, int* servi } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, audio_streaming_mode, &tmp_service_state, &tmp_forground, &tmp_daemon_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager initialize : Fail to invoke message, error(%d)", ret); return ret; } @@ -784,7 +798,12 @@ int vc_mgr_tidl_request_finalize(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_finalize(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager finalize : Fail to invoke message, error(%d)", ret); return ret; } @@ -807,7 +826,12 @@ int vc_mgr_tidl_request_set_command(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_command(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set command : Fail to invoke message, error(%d)", ret); return ret; } @@ -830,7 +854,12 @@ int vc_mgr_tidl_request_unset_command(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_unset_command(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager unset command : Fail to invoke message, error(%d)", ret); return ret; } @@ -853,7 +882,12 @@ int vc_mgr_tidl_request_demandable_client(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_demandable_client(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager demandable client : Fail to invoke message, error(%d)", ret); return ret; } @@ -876,7 +910,12 @@ int vc_mgr_tidl_request_set_audio_type(int pid, const char* audio_type) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_audio_type(g_proxy_tidl_info->rpc_h, pid, audio_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set audio type : Fail to invoke message, error(%d)", ret); return ret; } @@ -900,7 +939,12 @@ int vc_mgr_tidl_request_get_audio_type(int pid, char** audio_type) char *tmp = NULL; int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_audio_type(g_proxy_tidl_info->rpc_h, pid, &tmp); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get audio type : Fail to invoke message, error(%d)", ret); return ret; } @@ -946,7 +990,12 @@ int vc_mgr_tidl_request_get_private_data(int pid, const char* key, char** data) char *tmp = NULL; int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_private_data(g_proxy_tidl_info->rpc_h, pid, key, &tmp); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get private data : Fail to invoke message, error(%d)", ret); return ret; } @@ -972,7 +1021,12 @@ int vc_mgr_tidl_request_set_client_info(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_client_info(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set client info : Fail to invoke message, error(%d)", ret); return ret; } @@ -995,7 +1049,12 @@ int vc_mgr_tidl_request_set_domain(int pid, const char* domain) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_domain(g_proxy_tidl_info->rpc_h, pid, domain); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set domain : Fail to invoke message, error(%d)", ret); return ret; } @@ -1037,7 +1096,12 @@ int vc_mgr_tidl_request_start(int pid, int recognition_mode, bool exclusive_comm } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_start(g_proxy_tidl_info->rpc_h, pid, recognition_mode, exclusive_command_option, start_by_client, disabled_cmd_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager start : Fail to invoke message, error(%d)", ret); return ret; } @@ -1060,7 +1124,12 @@ int vc_mgr_tidl_request_stop(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_stop(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager stop : Fail to invoke message, error(%d)", ret); return ret; } @@ -1083,7 +1152,12 @@ int vc_mgr_tidl_request_cancel(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_cancel(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager cancel : Fail to invoke message, error(%d)", ret); return ret; } diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index e2c8b10..4f33b25 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -286,7 +286,7 @@ int vc_setting_tidl_request_hello() } -static int __covert_unhandled_error(int ret) +static int __convert_unhandled_error(int ret) { if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { return VC_ERROR_OPERATION_FAILED; @@ -304,9 +304,14 @@ int vc_setting_tidl_request_set_language(int pid, const char* language) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_setting_proxy_vc_setting_invoke_set_language(info->rpc_h, pid, language); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc setting set language : Fail to invoke message"); - return __covert_unhandled_error(ret); + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc setting set language : Fail to invoke message (%d)", ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc setting set language : pid(%d), language(%s)", pid, language); diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 2601636..46fc18a 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -421,7 +421,7 @@ int vc_tidl_request_hello() } -static int __covert_unhandled_error(int ret) +static int __convert_unhandled_error(int ret) { if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { return VC_ERROR_OPERATION_FAILED; @@ -439,9 +439,14 @@ int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* d RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : mgr = %d service = %d daemon_pid = %d", *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE @@ -458,9 +463,14 @@ int vc_tidl_request_finalize(int pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret); @@ -477,9 +487,14 @@ int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d), cmd_type(%d)", pid, cmd_type); @@ -496,9 +511,14 @@ int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), cmd_type(%d)", pid, cmd_type); @@ -516,9 +536,14 @@ int vc_tidl_request_set_foreground(int pid, bool value) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground : pid(%d), value(%d)", pid, value); @@ -535,9 +560,14 @@ int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* c RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s), credential(%s)", pid, app_id, credential); @@ -555,9 +585,14 @@ int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* u RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); @@ -574,9 +609,14 @@ int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid); @@ -594,9 +634,14 @@ int vc_tidl_request_auth_enable(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -613,9 +658,14 @@ int vc_tidl_request_auth_disable(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -632,9 +682,14 @@ int vc_tidl_request_auth_start(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -651,9 +706,14 @@ int vc_tidl_request_auth_stop(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -670,9 +730,14 @@ int vc_tidl_request_auth_cancel(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -695,9 +760,14 @@ int vc_tidl_request_request_tts(int pid, const char* text, const char* language, } int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_tts(info->rpc_h, pid, text, language, to_vcm, utt_id); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : pid(%d)", pid); @@ -714,9 +784,14 @@ int vc_tidl_request_cancel_tts(int pid, int utt_id) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : pid(%d), utt_id(%d)", pid, utt_id); @@ -733,9 +808,14 @@ int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type); diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index dbe49de..f1203ff 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -347,6 +347,15 @@ int vc_widget_tidl_close_connection() return VC_ERROR_NONE; } +static int __convert_unhandled_error(int ret) +{ + if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { + return VC_ERROR_OPERATION_FAILED; + } + + return ret; +} + static void __request_tidl_connect() { if (g_proxy_tidl_info->connection_requesting) { @@ -449,7 +458,12 @@ int vc_widget_tidl_request_initialize(int pid, int* service_state, int* daemon_p int temp_service_state = 0; int temp_daemon_pid = 0; int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, &temp_service_state, &temp_daemon_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget initialize : Fail to invoke message, error(%d)", ret); pthread_mutex_unlock(&g_w_init_mutex); return ret; @@ -482,7 +496,12 @@ int vc_widget_tidl_request_finalize(int pid) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_finalize(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget finalize : Fail to invoke message, error(%d)", ret); pthread_mutex_unlock(&g_w_init_mutex); return ret; @@ -507,7 +526,12 @@ int vc_widget_tidl_request_start_recording(int pid, bool command) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_start_recording(g_proxy_tidl_info->rpc_h, pid, (int)command); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start recording : Fail to invoke message, error(%d)", ret); return ret; } @@ -550,7 +574,12 @@ int vc_widget_tidl_request_enable_asr_result(int pid, bool enable) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_enable_asr_result(g_proxy_tidl_info->rpc_h, pid, (int)enable); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget enable asr result : Fail to invoke message, error(%d)", ret); return ret; } @@ -573,7 +602,12 @@ int vc_widget_tidl_request_start(int pid, int silence) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_start(g_proxy_tidl_info->rpc_h, pid, silence); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start : Fail to invoke message, error(%d)", ret); return ret; } @@ -596,7 +630,12 @@ int vc_widget_tidl_request_stop(int pid) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_stop(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget stop : Fail to invoke message, error(%d)", ret); return ret; } @@ -619,7 +658,12 @@ int vc_widget_tidl_request_cancel(int pid) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_cancel(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget cancel : Fail to invoke message, error(%d)", ret); return ret; } -- 2.7.4 From 6f1081df0ac124696d5650b117d3a6a8a17cd51d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Tue, 2 Aug 2022 14:55:20 +0900 Subject: [PATCH 16/16] Remove a logic to check TIDL privileges Change-Id: I82f566421225fd7d6e903fe45a7c30592e9fbf6c Signed-off-by: sooyeon --- client/vc.c | 22 ---------------------- client/vc_mgr.c | 18 ------------------ common/vc_command.c | 22 ---------------------- common/vc_defs.h | 2 -- server/vce.c | 22 ---------------------- 5 files changed, 86 deletions(-) diff --git a/client/vc.c b/client/vc.c index c61a3f0..2d91a48 100644 --- a/client/vc.c +++ b/client/vc.c @@ -178,28 +178,6 @@ static int __vc_check_privilege() //LCOV_EXCL_STOP } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - __check_privilege_deinitialize(); } diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 3746242..fcc1c81 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -246,24 +246,6 @@ static int __vc_mgr_check_privilege() return VC_ERROR_PERMISSION_DENIED; } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - } - __check_privilege_deinitialize(); } diff --git a/common/vc_command.c b/common/vc_command.c index 34138f3..f61a7a5 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -171,28 +171,6 @@ static int __vc_cmd_check_privilege() //LCOV_EXCL_STOP } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - __check_privilege_deinitialize(); } diff --git a/common/vc_defs.h b/common/vc_defs.h index d9a07b5..e163687 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -278,8 +278,6 @@ extern "C" { #define VC_PRIVILEGE_RECORDER "http://tizen.org/privilege/recorder" #define VC_MGR_PRIVILEGE "http://tizen.org/privilege/voicecontrol.manager" -#define VC_PRIVILEGE_DATASHARING "http://tizen.org/privilege/datasharing" -#define VC_PRIVILEGE_APPMGR "http://tizen.org/privilege/appmanager.launch" /****************************************************************************************** * Definitions for common enum diff --git a/server/vce.c b/server/vce.c index 1b4839f..98826b5 100644 --- a/server/vce.c +++ b/server/vce.c @@ -141,28 +141,6 @@ static int __vce_check_privilege() //LCOV_EXCL_STOP } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - __check_privilege_deinitialize(); } -- 2.7.4