From e55e36f20b0feff974fc35a7942fd0be1b434844 Mon Sep 17 00:00:00 2001 From: Lee Dongyeol Date: Fri, 21 Aug 2015 15:22:35 +0900 Subject: [PATCH 01/16] Update file path and IPC for smack issue Change-Id: Idb7026ae799d8cc59549b0dd68275d6c2e861501 --- CMakeLists.txt | 6 ++-- client/vc.c | 9 ++++-- client/vc_dbus.c | 47 ++++++------------------------- client/vc_mgr_dbus.c | 33 +++++++++------------- client/vc_widget.c | 11 ++++++-- client/vc_widget_dbus.c | 55 ++++++++++++------------------------ common/vc_config_mgr.c | 19 +++++++++++++ common/vc_config_parser.c | 7 +---- common/vc_defs.h | 23 ++++++--------- common/vc_info_parser.c | 7 +---- org.tizen.voice.vcserver.service | 3 +- packaging/voice-control.spec | 5 ++-- server/vcd_dbus.c | 60 ++++++++++++++-------------------------- server/vcd_server.c | 2 ++ 14 files changed, 111 insertions(+), 176 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4397548..bb93fa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,8 +52,6 @@ ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(server) ## config ## -INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION /usr/lib/voice/vc/1.0) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION /usr/share/voice/vc/) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-server.conf DESTINATION /etc/dbus-1/system.d) - -INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.vcserver.service DESTINATION /usr/share/dbus-1/system-services) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.vcserver.service DESTINATION /usr/share/dbus-1/services) diff --git a/client/vc.c b/client/vc.c index 825bb9e..f3bf651 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1134,7 +1134,7 @@ Eina_Bool __vc_notify_error(void *data) int __vc_cb_error(int pid, int reason) { if (0 != vc_client_get_handle(pid, &g_vc)) { - SLOG(LOG_ERROR, TAG_VCC, "Handle is not valid"); + SLOG(LOG_ERROR, TAG_VCC, "Handle is not valid : pid(%d)", pid); return -1; } @@ -1211,8 +1211,13 @@ static Eina_Bool __vc_notify_result(void *data) return EINA_FALSE; } -void __vc_cb_result(void) +void __vc_cb_result(int pid) { + if (0 != vc_client_get_handle(pid, &g_vc)) { + SLOG(LOG_ERROR, TAG_VCC, "Handle is not valid : pid(%d)", pid); + return; + } + ecore_timer_add(0, __vc_notify_result, NULL); return; diff --git a/client/vc_dbus.c b/client/vc_dbus.c index a9ccf9c..bcf3964 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -29,7 +29,7 @@ static DBusConnection* g_conn_listener = NULL; extern int __vc_cb_error(int pid, int reason); -extern void __vc_cb_result(); +extern void __vc_cb_result(int pid); extern int __vc_cb_service_state(int state); @@ -110,17 +110,20 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle } /* VCD_METHOD_SET_SERVICE_STATE */ - else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_RESULT)) { + else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_RESULT)) { SLOG(LOG_DEBUG, TAG_VCC, "===== Get Client Result"); - __vc_cb_result(); + int pid = 0; + dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); + + __vc_cb_result(pid); SLOG(LOG_DEBUG, TAG_VCC, "====="); SLOG(LOG_DEBUG, TAG_VCC, " "); } /* VCD_METHOD_RESULT */ - else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_ERROR)) { + else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCC, "===== Get Error"); int pid; int reason; @@ -166,13 +169,12 @@ int vc_dbus_open_connection() } DBusError err; - int ret; /* initialise 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_SYSTEM, &err); + g_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message); @@ -184,7 +186,7 @@ int vc_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } - g_conn_listener = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); + g_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message); @@ -196,25 +198,6 @@ int vc_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s", VC_CLIENT_SERVICE_NAME); - - 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); - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCC, "fail dbus_bus_request_name()"); - return -2; - } - if (NULL != g_fd_handler) { SLOG(LOG_WARN, TAG_VCC, "The handler already exists."); return 0; @@ -260,18 +243,6 @@ int vc_dbus_close_connection() g_fd_handler = NULL; } - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s", VC_CLIENT_SERVICE_NAME); - - 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); - dbus_error_free(&err); - } g_conn_sender = NULL; g_conn_listener = NULL; diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index b5b6b6f..9fc3a09 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -149,7 +149,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_SET_SERVICE_STATE */ - else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_SPEECH_DETECTED)) { + else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_SPEECH_DETECTED)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get Speech detected"); __vc_mgr_cb_speech_detected(); @@ -159,7 +159,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_SPEECH_DETECTED */ - else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_ALL_RESULT)) { + else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_ALL_RESULT)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get All Result"); int result_type = 0; @@ -172,7 +172,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_ALL_RESULT */ - else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_RESULT)) { + else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_RESULT)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get System Result"); __vc_mgr_cb_system_result(); @@ -182,7 +182,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_RESULT */ - else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_ERROR)) { + else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get Error"); int pid; int reason; @@ -197,8 +197,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCM, "<<<< vc mgr Get Error message : Get arguments error (%s)", err.message); dbus_error_free(&err); - } - else { + } else { SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr Get Error message : pid(%d), reason(%d), msg(%s)", pid, reason, err_msg); __vc_mgr_cb_error(pid, reason); } @@ -300,8 +299,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd 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 { + } else { SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr request auth start : pid(%d)", pid); ret = __vc_mgr_request_auth_start(pid); } @@ -319,8 +317,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc mgr request auth start : ret(%d)", ret); dbus_connection_flush(g_m_conn_listener); dbus_message_unref(reply); - } - else { + } else { SLOG(LOG_ERROR, TAG_VCM, ">>>> vc mgr request auth start : fail to create reply message"); } @@ -340,8 +337,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd 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 { + } else { SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr request auth stop : pid(%d)", pid); ret = __vc_mgr_request_auth_stop(pid); } @@ -359,8 +355,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc mgr request auth stop : ret(%d)", ret); dbus_connection_flush(g_m_conn_listener); dbus_message_unref(reply); - } - else { + } else { SLOG(LOG_ERROR, TAG_VCM, ">>>> vc mgr request auth stop : fail to create reply message"); } @@ -380,8 +375,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd 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 { + } else { SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr request auth cancel : pid(%d)", pid); ret = __vc_mgr_request_auth_cancel(pid); } @@ -399,8 +393,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc request auth cancel : ret(%d)", ret); dbus_connection_flush(g_m_conn_listener); dbus_message_unref(reply); - } - else { + } else { SLOG(LOG_ERROR, TAG_VCM, ">>>> vc mgr request auth cancel : fail to create reply message"); } @@ -435,7 +428,7 @@ int vc_mgr_dbus_open_connection() dbus_error_init(&err); /* connect to the DBUS system bus, and check for errors */ - g_m_conn_sender = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); + g_m_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCM, "Dbus Connection Error (%s)", err.message); @@ -448,7 +441,7 @@ int vc_mgr_dbus_open_connection() } /* connect to the DBUS system bus, and check for errors */ - g_m_conn_listener = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); + g_m_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCM, "Dbus Connection Error (%s)", err.message); diff --git a/client/vc_widget.c b/client/vc_widget.c index 7c11ab1..e8ae87b 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -777,7 +777,7 @@ static Eina_Bool __vc_widget_notify_error(void *data) int __vc_widget_cb_error(int pid, int reason) { if (0 != vc_widget_client_get_handle(pid, &g_vc_w)) { - SLOG(LOG_ERROR, TAG_VCW, "Handle is not valid"); + SLOG(LOG_ERROR, TAG_VCW, "Handle is not valid : pid(%d)", pid); return -1; } @@ -884,7 +884,7 @@ static Eina_Bool __vc_widget_notify_tooltip(void *data) void __vc_widget_cb_show_tooltip(int pid, bool show) { if (0 != vc_widget_client_get_handle(pid, &g_vc_w)) { - SLOG(LOG_ERROR, TAG_VCW, "Handle is not valid"); + SLOG(LOG_ERROR, TAG_VCW, "Handle is not valid : pid(%d)", pid); return; } @@ -934,8 +934,13 @@ static Eina_Bool __vc_widget_notify_result(void *data) return EINA_FALSE; } -void __vc_widget_cb_result() +void __vc_widget_cb_result(int pid) { + if (0 != vc_widget_client_get_handle(pid, &g_vc_w)) { + SLOG(LOG_ERROR, TAG_VCW, "Handle is not valid : pid(%d)", pid); + return; + } + ecore_timer_add(0, __vc_widget_notify_result, NULL); return; diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index 0ef4fe2..129b9b1 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -31,7 +31,7 @@ extern int __vc_widget_cb_error(int pid, int reason); extern void __vc_widget_cb_show_tooltip(int pid, bool show); -extern void __vc_widget_cb_result(); +extern void __vc_widget_cb_result(int pid); extern int __vc_widget_cb_service_state(int state); @@ -114,15 +114,15 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_WIDGET_METHOD_SET_SERVICE_STATE */ - else if (dbus_message_is_method_call(msg, if_name, VCD_WIDGET_METHOD_SHOW_TOOLTIP)) { + else if (dbus_message_is_signal(msg, if_name, VCD_WIDGET_METHOD_SHOW_TOOLTIP)) { SLOG(LOG_DEBUG, TAG_VCW, "===== Show / Hide tooltip"); int pid = 0; int show = 0; dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &show, - DBUS_TYPE_INVALID); + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &show, + DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Dbus Error (%s)", err.message); @@ -131,7 +131,6 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd if (pid > 0) { SLOG(LOG_DEBUG, TAG_VCW, "<<<< vc widget show tooltip : pid(%d), show(%d)", pid, show); - __vc_widget_cb_show_tooltip(pid, (bool)show); } else { SLOG(LOG_ERROR, TAG_VCW, "<<<< vc widget show tooltip : invalid pid"); @@ -141,10 +140,13 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCW, " "); } /* VCD_WIDGET_METHOD_SHOW_TOOLTIP */ - else if (dbus_message_is_method_call(msg, if_name, VCD_WIDGET_METHOD_RESULT)) { + else if (dbus_message_is_signal(msg, if_name, VCD_WIDGET_METHOD_RESULT)) { SLOG(LOG_DEBUG, TAG_VCW, "===== Get widget result"); - __vc_widget_cb_result(); + int pid = 0; + dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); + + __vc_widget_cb_result(pid); /* reply = dbus_message_new_method_return(msg); @@ -167,17 +169,17 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_WIDGET_METHOD_RESULT */ - else if (dbus_message_is_method_call(msg, if_name, VCD_WIDGET_METHOD_ERROR)) { + else if (dbus_message_is_signal(msg, if_name, VCD_WIDGET_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCW, "===== Get widget error"); 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); + 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_VCW, "<<<< vc widget get error message : Get arguments error (%s)", err.message); @@ -228,13 +230,12 @@ int vc_widget_dbus_open_connection() } DBusError err; - int ret; /* initialise the error value */ dbus_error_init(&err); /* connect to the DBUS system bus, and check for errors */ - g_w_conn_sender = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); + g_w_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "Dbus Connection Error (%s)", err.message); @@ -246,7 +247,7 @@ int vc_widget_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } - g_w_conn_listener = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); + g_w_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "Dbus Connection Error (%s)", err.message); @@ -258,21 +259,6 @@ int vc_widget_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCW, "service name is %s", VC_WIDGET_SERVICE_NAME); - - /* register our name on the bus, and check for errors */ - ret = dbus_bus_request_name(g_w_conn_listener, VC_WIDGET_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCW, "Name Error (%s)", err.message); - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCW, "fail dbus_bus_request_name()"); - return -2; - } - if (NULL != g_w_fd_handler) { SLOG(LOG_WARN, TAG_VCW, "The handler already exists."); return 0; @@ -319,13 +305,6 @@ int vc_widget_dbus_close_connection() g_w_fd_handler = NULL; } - dbus_bus_release_name(g_w_conn_listener, VC_WIDGET_SERVICE_NAME, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - g_w_conn_sender = NULL; g_w_conn_listener = NULL; diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 2e38474..94974d3 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -529,9 +529,28 @@ int vc_config_mgr_initialize(int uid) SLOG(LOG_WARN, vc_config_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid); __vc_config_mgr_print_client_info(); + return 0; } + if (0 != access(VC_CONFIG_BASE, F_OK)) { + if (0 != mkdir(VC_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to make directory : %s", VC_CONFIG_BASE); + return -1; + } else { + SLOG(LOG_DEBUG, vc_config_tag(), "Success to make directory : %s", VC_CONFIG_BASE); + } + } + + if (0 != access(VC_RUNTIME_INFO_ROOT, F_OK)) { + if (0 != mkdir(VC_RUNTIME_INFO_ROOT, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to make directory : %s", VC_RUNTIME_INFO_ROOT); + return -1; + } else { + SLOG(LOG_DEBUG, vc_config_tag(), "Success to make directory : %s", VC_RUNTIME_INFO_ROOT); + } + } + /* Get file name from default engine directory */ DIR *dp = NULL; int ret = -1; diff --git a/common/vc_config_parser.c b/common/vc_config_parser.c index 3e984d4..5001a1f 100644 --- a/common/vc_config_parser.c +++ b/common/vc_config_parser.c @@ -56,12 +56,7 @@ static int __vc_config_parser_set_file_mode(const char* filename) if (0 > chmod(filename, 0666)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to change file mode"); - return -1; - } - - if (0 > chown(filename, 5000, 5000)) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to change file owner"); - return -1; + /* return -1; */ } return 0; diff --git a/common/vc_defs.h b/common/vc_defs.h index f794278..161c39e 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -140,9 +140,10 @@ extern "C" { #define VC_DAEMON_PATH "/usr/bin/vc-daemon" -#define VC_CONFIG_DEFAULT "/usr/lib/voice/vc/1.0/vc-config.xml" +#define VC_CONFIG_DEFAULT "/usr/share/voice/vc/vc-config.xml" -#define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, ".voice/vc-config.xml") +#define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/voice") +#define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc-config.xml") #define VC_DEFAULT_ENGINE_INFO "/usr/lib/voice/vc/1.0/engine-info" @@ -153,23 +154,17 @@ extern "C" { #define VC_RETRY_COUNT 5 -#define VC_CONFIG_ROOT tzplatform_mkpath(TZ_USER_HOME, ".voice") +#define VC_RUNTIME_INFO_ROOT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc") -#define VC_RUNTIME_INFO_ROOT tzplatform_mkpath(TZ_USER_HOME, ".voice/vc") +#define VC_RUNTIME_INFO_FOREGROUND tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-info-foreground.xml") -#define VC_RUNTIME_INFO_AUDIO_VOLUME tzplatform_mkpath(TZ_USER_HOME, ".voice/vc/vc_vol") +#define VC_RUNTIME_INFO_DEMANDABLE_LIST tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-demandable-client.xml") -#define VC_RUNTIME_INFO_FOREGROUND tzplatform_mkpath(TZ_USER_HOME, ".voice/vc/vc-info-foreground.xml") +#define VC_RUNTIME_INFO_RESULT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-result.xml") -#define VC_RUNTIME_INFO_SERVICE_STATE tzplatform_mkpath(TZ_USER_HOME, ".voice/vc/vc-info-state.xml") +#define VC_RUNTIME_INFO_EX_RESULT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-ex-result.xml") -#define VC_RUNTIME_INFO_DEMANDABLE_LIST tzplatform_mkpath(TZ_USER_HOME, ".voice/vc/vc-demandable-client.xml") - -#define VC_RUNTIME_INFO_RESULT tzplatform_mkpath(TZ_USER_HOME, ".voice/vc/vc-result.xml") - -#define VC_RUNTIME_INFO_EX_RESULT tzplatform_mkpath(TZ_USER_HOME, ".voice/vc/vc-ex-result.xml") - -#define VC_RUNTIME_INFO_CLIENT tzplatform_mkpath(TZ_USER_HOME, ".voice/vc/vc-client-info.xml") +#define VC_RUNTIME_INFO_CLIENT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-client-info.xml") /****************************************************************************************** * Defines for common enum diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index a187a86..44decad 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -77,12 +77,7 @@ static int __vc_info_parser_set_file_mode(const char* filename) if (0 > chmod(filename, 0666)) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to change file mode"); - return -1; - } - - if (0 > chown(filename, 5000, 5000)) { - SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to change file owner"); - return -1; + /*return -1;*/ } return 0; diff --git a/org.tizen.voice.vcserver.service b/org.tizen.voice.vcserver.service index 638d1dc..6fd1b9b 100644 --- a/org.tizen.voice.vcserver.service +++ b/org.tizen.voice.vcserver.service @@ -1,5 +1,4 @@ [D-BUS Service] Name=org.tizen.voice.vcserver Exec=/usr/bin/vc-daemon -User=system -Group=system + diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index e92e105..e154945 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -109,9 +109,8 @@ mkdir -p /usr/share/voice/vc %{_libdir}/libvc_widget.so %{_libdir}/libvc_manager.so %{_bindir}/vc-daemon -/usr/share/dbus-1/system-services/org.tizen.voice* -/etc/dbus-1/system.d/vc-server.conf -/usr/lib/voice/vc/1.0/vc-config.xml +/usr/share/dbus-1/services/org.tizen.voice* +/usr/share/voice/vc/vc-config.xml /usr/share/license/%{name} %files devel diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 6d21801..49f5fa7 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -26,8 +26,6 @@ static DBusConnection* g_conn_listener = NULL; static Ecore_Fd_Handler* g_dbus_fd_handler = NULL; -static int g_waiting_time = 3000; - static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e type) { @@ -38,7 +36,7 @@ static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e if (VCD_CLIENT_TYPE_NORMAL == type) { snprintf(service_name, 64, "%s", VC_CLIENT_SERVICE_NAME); snprintf(object_path, 64, "%s", VC_CLIENT_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s", VC_CLIENT_SERVICE_NAME); + snprintf(target_if_name, 128, "%s", VC_CLIENT_SERVICE_INTERFACE); } else if (VCD_CLIENT_TYPE_WIDGET == type) { snprintf(service_name, 64, "%s", VC_WIDGET_SERVICE_NAME); @@ -53,11 +51,12 @@ static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e return NULL; } - return dbus_message_new_method_call(service_name, object_path, target_if_name, method); + return dbus_message_new_signal(object_path, target_if_name, method); } int vcdc_send_hello(int pid, vcd_client_type_e type) { +#if 0 DBusMessage* msg = NULL; if (VCD_CLIENT_TYPE_NORMAL == type) { @@ -108,6 +107,8 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) } return result; +#endif + return 1; } int vcdc_send_show_tooltip(int pid, bool show) @@ -117,22 +118,14 @@ int vcdc_send_show_tooltip(int pid, bool show) return -1; } - char service_name[64] = {0, }; - memset(service_name, 0, 64); - snprintf(service_name, 64, "%s", VC_WIDGET_SERVICE_NAME); - - char target_if_name[128] = {0, }; - snprintf(target_if_name, sizeof(target_if_name), "%s", VC_WIDGET_SERVICE_INTERFACE); - DBusMessage* msg; SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] send widget show tooltip signal : pid(%d) show(%d)", pid, show); - msg = dbus_message_new_method_call( - service_name, - VC_WIDGET_SERVICE_OBJECT_PATH, - target_if_name, - VCD_WIDGET_METHOD_SHOW_TOOLTIP); + msg = dbus_message_new_signal( + VC_WIDGET_SERVICE_OBJECT_PATH, + VC_WIDGET_SERVICE_INTERFACE, + VCD_WIDGET_METHOD_SHOW_TOOLTIP); if (NULL == msg) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message"); @@ -148,8 +141,6 @@ int vcdc_send_show_tooltip(int pid, bool show) dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &pid); dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(temp)); - dbus_message_set_no_reply(msg, TRUE); - 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; @@ -225,7 +216,7 @@ int vcdc_send_result(int pid, int cmd_type) return VCD_ERROR_OUT_OF_MEMORY; } - dbus_message_set_no_reply(msg, TRUE); + dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); @@ -258,8 +249,6 @@ int vcdc_send_result_to_manager(int manger_pid, int result_type) dbus_message_append_args(msg, DBUS_TYPE_INT32, &result_type, DBUS_TYPE_INVALID); - dbus_message_set_no_reply(msg, TRUE); - 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; @@ -288,8 +277,6 @@ int vcdc_send_speech_detected(int manger_pid) return VCD_ERROR_OUT_OF_MEMORY; } - dbus_message_set_no_reply(msg, TRUE); - 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; @@ -392,18 +379,13 @@ int vcdc_send_error_signal(int pid, int reason, char *err_msg) return VCD_ERROR_INVALID_PARAMETER; } - char service_name[64]; - memset(service_name, 0, 64); - snprintf(service_name, 64, "%s", VC_CLIENT_SERVICE_NAME); - DBusMessage* msg; SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] send error signal : reason(%d), Error Msg(%s)", reason, err_msg); - msg = dbus_message_new_method_call( - service_name, - VC_CLIENT_SERVICE_OBJECT_PATH, - VC_CLIENT_SERVICE_INTERFACE, - VCD_METHOD_ERROR); + 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] Fail to create message"); @@ -411,12 +393,10 @@ int vcdc_send_error_signal(int pid, int reason, char *err_msg) } 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); + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &reason, + 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"); @@ -548,7 +528,7 @@ int vcd_dbus_open_connection() int ret; /* Create connection for sender */ - g_conn_sender = dbus_bus_get(DBUS_BUS_SYSTEM, &err); + g_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); @@ -561,7 +541,7 @@ int vcd_dbus_open_connection() } /* connect to the bus and check for errors */ - g_conn_listener = dbus_bus_get(DBUS_BUS_SYSTEM, &err); + g_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); diff --git a/server/vcd_server.c b/server/vcd_server.c index a098af4..a4c2bb7 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -570,6 +570,7 @@ static Eina_Bool __finalize_quit_ecore_loop(void *data) Eina_Bool vcd_cleanup_client(void *data) { +#if 0 int* client_list = NULL; int client_count = 0; int result; @@ -596,6 +597,7 @@ Eina_Bool vcd_cleanup_client(void *data) free(client_list); client_list = NULL; } +#endif #if 0 /* If app is in background state, app cannot response message. */ -- 2.7.4 From 70e7514fc09c6eda33de434c267f63fddd23aeb6 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 7 Sep 2015 11:06:35 +0900 Subject: [PATCH 02/16] updates codes to check model config feature Change-Id: I7ed31729cde6265457422282b436dfa9f3c63200 --- CMakeLists.txt | 4 +- changelog | 4 ++ client/vc.c | 110 ++++++++++++++++++++++++++++++++++ common/vc_command.c | 138 +++++++++++++++++++++++++++++++++++++++++++ common/vc_defs.h | 3 + doc/uix_vc_doc.h | 28 ++++----- packaging/voice-control.spec | 3 +- 7 files changed, 273 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb93fa6..d978245 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 0.2.9) +SET(VERSION 0.2.10) # pkg config tool INCLUDE(FindPkgConfig) @@ -38,7 +38,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") ## Dependent packages ## INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED - aul capi-base-common capi-media-audio-io capi-media-sound-manager capi-network-bluetooth + aul capi-base-common capi-media-audio-io capi-media-sound-manager capi-network-bluetooth capi-system-info dbus-1 dlog ecore glib-2.0 libprivilege-control libxml-2.0 vconf ) diff --git a/changelog b/changelog index 9f2aae1..423a38d 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +voice-control (0.2.10) -- Thu, 27 Aug 2015 + + * Add tizen.org/feature/speech.control feature check (Dongyeol Lee ) + voice-control (0.2.9) -- Mon, 6 Jul 2015 * Update daemon start by dbus activation (Dongyeol Lee ) diff --git a/client/vc.c b/client/vc.c index f3bf651..1cad371 100644 --- a/client/vc.c +++ b/client/vc.c @@ -15,6 +15,7 @@ */ #include +#include #include "vc_client.h" #include "vc_command.h" @@ -33,6 +34,8 @@ static Ecore_Timer* g_connect_timer = NULL; static vc_h g_vc = NULL; +static int g_feature_enabled = -1; + #if 0 static Ecore_Event_Handler* g_focus_in_hander = NULL; static Ecore_Event_Handler* g_focus_out_hander = NULL; @@ -41,6 +44,29 @@ static Ecore_Event_Handler* g_focus_out_hander = NULL; Eina_Bool __vc_notify_state_changed(void *data); Eina_Bool __vc_notify_error(void *data); +static int __vc_get_feature_enabled() +{ + if (0 == g_feature_enabled) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); + return VC_ERROR_NOT_SUPPORTED; + } else if (-1 == g_feature_enabled) { + bool vc_supported = false; + bool mic_supported = false; + if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { + if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { + if (false == vc_supported || false == mic_supported) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); + g_feature_enabled = 0; + return VC_ERROR_NOT_SUPPORTED; + } + + g_feature_enabled = 1; + } + } + } + + return 0; +} static const char* __vc_get_error_code(vc_error_e err) { @@ -122,6 +148,10 @@ static Eina_Bool __notify_auth_changed_cb(void *data) int vc_initialize(void) { + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Initialize"); /* check handle */ @@ -202,6 +232,10 @@ static void __vc_internal_unprepare(void) int vc_deinitialize(void) { + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Deinitialize"); if (false == vc_client_is_valid(g_vc)) { @@ -381,6 +415,10 @@ static Eina_Bool __vc_connect_daemon(void *data) int vc_prepare(void) { + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Prepare"); vc_state_e state; @@ -409,6 +447,10 @@ int vc_prepare(void) int vc_unprepare(void) { + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Unprepare"); vc_state_e state; @@ -440,6 +482,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; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Foreach Supported Language"); if (NULL == callback) { @@ -473,6 +519,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; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get Current Language"); if (NULL == language) { @@ -505,6 +555,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; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get State"); if (NULL == state) { @@ -537,6 +591,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; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get Service State"); if (NULL == state) { @@ -720,6 +778,10 @@ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) 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; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Set Command list"); if (NULL == vc_cmd_list) { @@ -787,6 +849,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; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Unset Command list"); vc_state_e state; @@ -874,6 +940,10 @@ int vc_get_exclusive_command_option(bool* value) int vc_set_exclusive_command_option(bool value) { + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Set exclusive command"); vc_state_e state; @@ -1225,6 +1295,10 @@ void __vc_cb_result(int pid) int vc_set_result_cb(vc_result_cb callback, void* user_data) { + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1247,6 +1321,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; + } + vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : A handle is not available"); @@ -1298,6 +1376,10 @@ int __vc_cb_service_state(int state) 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; + } + if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1320,6 +1402,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; + } + vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : A handle is not available"); @@ -1339,6 +1425,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; + } + if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -1361,6 +1451,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; + } + vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset state changed callback : A handle is not available"); @@ -1380,6 +1474,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; + } + if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1402,6 +1500,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; + } + vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset current language changed : A handle is not available"); @@ -1421,6 +1523,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; + } + if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1443,6 +1549,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; + } + vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset error callback : A handle is not available"); diff --git a/common/vc_command.c b/common/vc_command.c index c06d828..f4fb2ef 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -17,6 +17,7 @@ #include #include +#include #include "vc_command.h" #include "vc_main.h" @@ -25,9 +26,38 @@ #include "voice_control_common.h" #include "voice_control_key_defines.h" +static int g_feature_enabled = -1; + +static int __vc_cmd_get_feature_enabled() +{ + if (0 == g_feature_enabled) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); + return VC_ERROR_NOT_SUPPORTED; + } else if (-1 == g_feature_enabled) { + bool vc_supported = false; + bool mic_supported = false; + if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { + if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { + if (false == vc_supported || false == mic_supported) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); + g_feature_enabled = 0; + return VC_ERROR_NOT_SUPPORTED; + } + + g_feature_enabled = 1; + } + } + } + + return 0; +} int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -52,6 +82,10 @@ int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list) int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool release_command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -74,6 +108,10 @@ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool release_command) int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list || NULL == count) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Get command count : Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -91,6 +129,10 @@ int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count) int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list || NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -115,6 +157,10 @@ int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command) int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list || NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -165,6 +211,10 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command) int vc_cmd_list_remove_all(vc_cmd_list_h vc_cmd_list, bool release_command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + SLOG(LOG_DEBUG, TAG_VCCMD, "===== Destroy all command"); if (NULL == vc_cmd_list) { @@ -209,6 +259,10 @@ int vc_cmd_list_remove_all(vc_cmd_list_h vc_cmd_list, bool release_command) int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -244,6 +298,10 @@ int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callb int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -264,6 +322,10 @@ int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list) int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -287,6 +349,10 @@ int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list) int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -310,6 +376,10 @@ int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list) int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -331,6 +401,10 @@ int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list) int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_cmd_list || NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -360,6 +434,10 @@ int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command) int vc_cmd_create(vc_cmd_h* vc_command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -392,6 +470,10 @@ int vc_cmd_create(vc_cmd_h* vc_command) int vc_cmd_destroy(vc_cmd_h vc_command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -414,6 +496,10 @@ int vc_cmd_destroy(vc_cmd_h vc_command) int vc_cmd_set_id(vc_cmd_h vc_command, int id) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -432,6 +518,10 @@ int vc_cmd_set_id(vc_cmd_h vc_command, int id) int vc_cmd_get_id(vc_cmd_h vc_command, int* id) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command || NULL == id) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); return VC_ERROR_INVALID_PARAMETER; @@ -450,6 +540,10 @@ int vc_cmd_get_id(vc_cmd_h vc_command, int* id) int vc_cmd_set_command(vc_cmd_h vc_command, const char* command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -475,6 +569,10 @@ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command) int vc_cmd_get_command(vc_cmd_h vc_command, char** command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command || NULL == command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); return VC_ERROR_INVALID_PARAMETER; @@ -494,6 +592,10 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command) int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -518,6 +620,10 @@ int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command) int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command || NULL == command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); return VC_ERROR_INVALID_PARAMETER; @@ -536,6 +642,10 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) int vc_cmd_set_type(vc_cmd_h vc_command, int type) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -553,6 +663,10 @@ int vc_cmd_set_type(vc_cmd_h vc_command, int type) int vc_cmd_get_type(vc_cmd_h vc_command, int* type) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command || NULL == type) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -570,6 +684,10 @@ int vc_cmd_get_type(vc_cmd_h vc_command, int* type) int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -587,6 +705,10 @@ int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format) int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command || NULL == format) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -604,6 +726,10 @@ int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format) int vc_cmd_set_pid(vc_cmd_h vc_command, int pid) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -621,6 +747,10 @@ int vc_cmd_set_pid(vc_cmd_h vc_command, int pid) int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command || NULL == pid) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -638,6 +768,10 @@ int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid) int vc_cmd_set_domain(vc_cmd_h vc_command, int domain) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; @@ -655,6 +789,10 @@ int vc_cmd_set_domain(vc_cmd_h vc_command, int domain) int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain) { + if (0 != __vc_cmd_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_command || NULL == domain) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); return VC_ERROR_INVALID_PARAMETER; diff --git a/common/vc_defs.h b/common/vc_defs.h index 161c39e..03344ed 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -166,6 +166,9 @@ extern "C" { #define VC_RUNTIME_INFO_CLIENT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-client-info.xml") +#define VC_FEATURE_PATH "tizen.org/feature/speech.control" +#define VC_MIC_FEATURE_PATH "tizen.org/feature/microphone" + /****************************************************************************************** * Defines for common enum *******************************************************************************************/ diff --git a/doc/uix_vc_doc.h b/doc/uix_vc_doc.h index ba34513..ac100b1 100644 --- a/doc/uix_vc_doc.h +++ b/doc/uix_vc_doc.h @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -22,35 +22,34 @@ * @defgroup CAPI_UIX_VOICE_CONTROL_MODULE Voice control * @ingroup CAPI_UIX_FRAMEWORK * @brief The @ref CAPI_UIX_VOICE_CONTROL_MODULE API provides functions for registering command and getting notification when registered command is recognized. - * + * * @section CAPI_UIX_VOICE_CONTROL_MODULE_HEADER Required Header * \#include
- * + * * @section CAPI_UIX_VOICE_CONTROL_MODULE_OVERVIEW Overview * A main function of Voice Control API register command and gets notification for recognition result. * Applications can add their own commands and be provided result when their command is recognized by user voice input. - * - * To use of Voice Control, use the following steps: + * + * To use of Voice Control, use the following steps:
* 1. Initialize
- * 2. Register callback functions for notifications
+ * 2. Register callback functions for notifications
* 3. Connect to voice control service asynchronously. The state should be changed to Ready
- * 4. Make command list as the following step
+ * 4. Make command list as the following step and Step 4 is called repeatedly for each command which an application wants
* 4-1. Create command list handle
* 4-2. Create command handle
* 4-3. Set command and type for command handle
* 4-4. Add command handle to command list
- * Step 4 is called repeatedly for each command which an application wants
* 5. Set command list for recognition
* 6. If an application wants to finish voice control,
* 6-1. Destroy command and command list handle
* 6-2. Deinitialize
* - * An application can obtain command handle from command list, and also get information from handle. + * An application can obtain command handle from command list, and also get information from handle. * * - * The Voice Control API also notifies you (by callback mechanism) when the states of client and service are changed, + * The Voice Control API also notifies you (by callback mechanism) when the states of client and service are changed, * command is recognized, current language is changed or error occurred. - * An application should register callback functions: vc_state_changed_cb(), vc_service_state_changed_cb(), vc_result_cb(), + * An application should register callback functions: vc_state_changed_cb(), vc_service_state_changed_cb(), vc_result_cb(), * vc_current_language_changed_cb(), vc_error_cb(). * * @section CAPI_UIX_VOICE_CONTROL_MODULE_STATE_DIAGRAM State Diagram @@ -100,7 +99,7 @@ * The following table shows state-dependent function calls. * It is forbidden to call functions listed below in wrong states. * Violation of this rule may result in an unpredictable behavior. - * + * * * * @@ -173,10 +172,11 @@ * * *
FUNCTION All callback function should be registered in Initialized state
- * - * @section CAPI_UIX_STT_MODULE_FEATURE Related Features + * + * @section CAPI_UIX_VOICE_CONTROL_MODULE Related Features * This API is related with the following features:
* - http://tizen.org/feature/microphone
+ * - http://tizen.org/feature/speech.control
* * It is recommended to design feature related codes in your application for reliability.
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.
diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index e154945..575da96 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: 0.2.9 +Version: 0.2.10 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 @@ -15,6 +15,7 @@ BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-media-audio-io) BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(capi-network-bluetooth) +BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) -- 2.7.4 From b7bd245b32e593b49e64c1e2a9d06654e5888f60 Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Thu, 22 Oct 2015 21:41:31 +0900 Subject: [PATCH 03/16] Clean up code Change-Id: Ia7bdec0da95e0211fa913986e60021344acc412b --- server/vcd_recorder.c | 235 -------------------------------------------------- 1 file changed, 235 deletions(-) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index e22ae75..c2d1607 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -26,12 +26,6 @@ #include "vcd_main.h" #include "voice_control_plugin_engine.h" -/* Multi session enable */ -/*#define AUDIO_MULTI_SESSION */ - -/* TV BT enable */ -/*#define TV_BT_MODE */ - #define FRAME_LENGTH 160 #define BUFFER_LENGTH FRAME_LENGTH * 2 @@ -59,10 +53,6 @@ static bool g_is_valid_bt_in = false; static char* g_current_audio_type = NULL; -#ifdef AUDIO_MULTI_SESSION -static sound_multi_session_h g_session = NULL; -#endif - static int g_buffer_count; /* Sound buf save */ @@ -78,84 +68,6 @@ static int g_count = 1; static float get_volume_decibel(char* data, int size); -#ifdef TV_BT_MODE -static int g_bt_extend_count; - -#define SMART_CONTROL_EXTEND_CMD 0x03 -#define SMART_CONTROL_START_CMD 0x04 - -static void _bt_cb_hid_state_changed(int result, bool connected, const char *remote_address, void *user_data) -{ - SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Bluetooth Event [%d] Received address [%s]", result, remote_address); - return; -} - -static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void *user_data) -{ - if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) { - /*SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Exit audio reading normal func");*/ - return; - } - - if (NULL != g_audio_cb) { - if (0 != g_audio_cb((void*)voice_data->audio_buf, (unsigned int)voice_data->length)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to read audio"); - vcd_recorder_stop(); - } - } - - /* Set volume */ - if (0 == g_buffer_count % 30) { - float vol_db = get_volume_decibel((char*)voice_data->audio_buf, (unsigned int)voice_data->length); - if (0 != vcdc_send_set_volume(vcd_client_manager_get_pid(), vol_db)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder] Fail to send recording volume(%f)", vol_db); - } - } - - if (0 == g_buffer_count || 0 == g_buffer_count % 50) { - SLOG(LOG_WARN, TAG_VCD, "[Recorder][%d] Recording... : read_size(%d)", g_buffer_count, voice_data->length); - - if (0 == g_bt_extend_count % 5) { - const unsigned char input_data[2] = {SMART_CONTROL_EXTEND_CMD, 0x00 }; - if (BT_ERROR_NONE != bt_hid_send_rc_command(NULL, input_data, sizeof(input_data))) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_send_rc_command(NULL, %s, %d)", input_data, sizeof(input_data)); - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Extend bt audio recorder"); - } - } - g_bt_extend_count++; - - if (100000 == g_buffer_count) { - g_buffer_count = 0; - } - } - - g_buffer_count++; - -#ifdef BUF_SAVE_MODE - /* write pcm buffer */ - fwrite(voice_data->audio_buf, 1, voice_data->length, g_normal_file); -#endif - return; -} - -#endif - -#ifdef AUDIO_MULTI_SESSION -void __vcd_recorder_sound_interrupted_cb(sound_interrupted_code_e code, void *user_data) -{ - SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Get the interrupt code from sound mgr : %d", code); - - if (SOUND_INTERRUPTED_BY_CALL == code) { - if (NULL != g_interrupt_cb) { - g_interrupt_cb(); - } - } - - return; -} -#endif - int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb interrupt_cb) { if (NULL == audio_cb || NULL == interrupt_cb) { @@ -164,29 +76,7 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb } int ret = 0; -#ifdef AUDIO_MULTI_SESSION - g_session = NULL; - ret = sound_manager_multi_session_create(SOUND_MULTI_SESSION_TYPE_VOICE_RECOGNITION, &g_session); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to create multi session : %d", ret); - return VCD_ERROR_OPERATION_FAILED; - } - ret = sound_manager_set_interrupted_cb(__vcd_recorder_sound_interrupted_cb, NULL); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set interrupt callback : %d", ret); - sound_manager_multi_session_destroy(g_session); - return VCD_ERROR_OPERATION_FAILED; - } - - ret = sound_manager_multi_session_set_mode(g_session, SOUND_MULTI_SESSION_MODE_VR_NORMAL); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set mode : %d", ret); - sound_manager_unset_interrupted_cb(); - sound_manager_multi_session_destroy(g_session); - return VCD_ERROR_OPERATION_FAILED; - } -#endif /* set init value */ g_is_valid_audio_in = false; g_is_valid_bt_in = false; @@ -217,18 +107,9 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb break; } - /* - ret = audio_in_create_ex(sample_rate, audio_ch, audio_type, &g_audio_h, AUDIO_IO_SOURCE_TYPE_VOICECONTROL); - */ ret = audio_in_create(g_audio_rate, audio_ch, audio_type, &g_audio_h); if (AUDIO_IO_ERROR_NONE == ret) { g_is_valid_audio_in = true; - /* - ret = audio_in_ignore_session(g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to ignore session : %d", ret); - } - */ } else { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Rate(%d) Channel(%d) Type(%d)", g_audio_rate, audio_ch, audio_type); SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to create audio handle : %d", ret); @@ -239,31 +120,6 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb g_interrupt_cb = interrupt_cb; g_recorder_state = VCD_RECORDER_STATE_READY; -#ifdef TV_BT_MODE - - bool is_bt_failed = false; - - if (false == is_bt_failed && BT_ERROR_NONE != bt_initialize()) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to init bt"); - is_bt_failed = true; - } - - if (false == is_bt_failed && BT_ERROR_NONE != bt_hid_host_initialize(_bt_cb_hid_state_changed, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_host_initialize()"); - is_bt_failed = true; - } - - if (false == is_bt_failed && BT_ERROR_NONE != bt_hid_set_audio_data_receive_cb(_bt_hid_audio_data_receive_cb, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_set_audio_data_receive_cb()"); - is_bt_failed = true; - } - - - if (false == is_bt_failed) { - SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Bluetooth is available"); - g_is_valid_bt_in = true; - } -#endif /* Select default audio type */ if (true == g_is_valid_bt_in) { g_current_audio_type = strdup(VCP_AUDIO_ID_BLUETOOTH); @@ -281,29 +137,12 @@ int vcd_recorder_destroy() if (VCD_RECORDER_STATE_RECORDING == g_recorder_state) { if (0 != strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) { audio_in_unprepare(g_audio_h); - } else { -#ifdef TV_BT_MODE - bt_hid_unset_audio_data_receive_cb(); -#endif } g_recorder_state = VCD_RECORDER_STATE_READY; } audio_in_destroy(g_audio_h); -#ifdef AUDIO_MULTI_SESSION - sound_manager_unset_interrupted_cb(); - sound_manager_multi_session_destroy(g_session); -#endif - -#ifdef TV_BT_MODE - bt_hid_unset_audio_data_receive_cb(); - - bt_hid_host_deinitialize(); - - bt_deinitialize(); -#endif - g_audio_cb = NULL; if (NULL != g_current_audio_type) { @@ -387,29 +226,6 @@ int vcd_recorder_set(const char* audio_type, vcp_audio_type_e type, int rate, in g_audio_rate = rate; g_audio_channel = channel; } - -#ifdef TV_BT_MODE - char* temp_type = NULL; - temp_type = strdup(audio_type); - - ret = audio_in_set_device(g_audio_h, temp_type); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder] Audio type is NOT valid :%s", temp_type); - if (NULL != temp_type) - free(temp_type); - return VCD_ERROR_OPERATION_REJECTED; - } - - if (NULL != temp_type) - free(temp_type); - - if (NULL != g_current_audio_type) { - free(g_current_audio_type); - g_current_audio_type = NULL; - } - - g_current_audio_type = strdup(audio_type); -#endif } SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Current audio type is changed : %s", g_current_audio_type); @@ -522,42 +338,11 @@ int vcd_recorder_start() if (VCD_RECORDER_STATE_RECORDING == g_recorder_state) return 0; -#ifdef AUDIO_MULTI_SESSION - ret = sound_manager_multi_session_set_option(g_session, SOUND_MULTI_SESSION_OPT_MIX_WITH_OTHERS); - if (0 != ret) { - if (SOUND_MANAGER_ERROR_POLICY_BLOCKED_BY_CALL == ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] blocked to set option by call"); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set option : %d", ret); - } - return VCD_ERROR_RECORDER_BUSY; - } -#endif bool started = false; - if (NULL != g_current_audio_type) { - if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) { -#ifdef TV_BT_MODE - const unsigned char input_data[2] = {SMART_CONTROL_START_CMD, 0x00 }; - if (BT_ERROR_NONE != bt_hid_send_rc_command(NULL, input_data, sizeof(input_data))) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_send_rc_command(NULL, %s, %d)", input_data, sizeof(input_data)); - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Start bt audio recorder"); - } - - started = true; - - g_bt_extend_count = 0; -#endif - } - } - if (false == started) { ret = audio_in_prepare(g_audio_h); if (AUDIO_IO_ERROR_NONE != ret) { if (AUDIO_IO_ERROR_SOUND_POLICY == ret) { -#ifdef AUDIO_MULTI_SESSION - sound_manager_multi_session_set_option(g_session, SOUND_MULTI_SESSION_OPT_RESUME_OTHERS); -#endif SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Audio is busy."); return VCD_ERROR_RECORDER_BUSY; } else { @@ -603,18 +388,6 @@ int vcd_recorder_stop() #endif bool stoped = false; - - if (NULL != g_current_audio_type) { - if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) { -#ifdef TV_BT_MODE - if (BT_ERROR_NONE != bt_hid_rc_stop_sending_voice(NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_rc_stop_sending_voice()"); - } - stoped = true; -#endif - } - } - if (false == stoped) { ret = audio_in_unprepare(g_audio_h); if (AUDIO_IO_ERROR_NONE != ret) { @@ -622,14 +395,6 @@ int vcd_recorder_stop() return VCD_ERROR_OPERATION_FAILED; } } - -#ifdef AUDIO_MULTI_SESSION - ret = sound_manager_multi_session_set_option(g_session, SOUND_MULTI_SESSION_OPT_RESUME_OTHERS); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set option : %d", ret); - return VCD_ERROR_OPERATION_FAILED; - } -#endif return 0; } -- 2.7.4 From c6ef0a6c7a3c4aa5b3794dd32f07ab6a6591a317 Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Fri, 23 Oct 2015 19:41:41 +0900 Subject: [PATCH 04/16] Fix file path for multi user Change-Id: Ie809c02c5b9e5f8f7247dc262a652a7717e75efd --- common/vc_defs.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/common/vc_defs.h b/common/vc_defs.h index 03344ed..c591038 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -142,8 +142,8 @@ extern "C" { #define VC_CONFIG_DEFAULT "/usr/share/voice/vc/vc-config.xml" -#define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/voice") -#define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc-config.xml") +#define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice") +#define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc-config.xml") #define VC_DEFAULT_ENGINE_INFO "/usr/lib/voice/vc/1.0/engine-info" @@ -154,17 +154,17 @@ extern "C" { #define VC_RETRY_COUNT 5 -#define VC_RUNTIME_INFO_ROOT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc") +#define VC_RUNTIME_INFO_ROOT tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc") -#define VC_RUNTIME_INFO_FOREGROUND tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-info-foreground.xml") +#define VC_RUNTIME_INFO_FOREGROUND tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc/vc-info-foreground.xml") -#define VC_RUNTIME_INFO_DEMANDABLE_LIST tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-demandable-client.xml") +#define VC_RUNTIME_INFO_DEMANDABLE_LIST tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc/vc-demandable-client.xml") -#define VC_RUNTIME_INFO_RESULT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-result.xml") +#define VC_RUNTIME_INFO_RESULT tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc/vc-result.xml") -#define VC_RUNTIME_INFO_EX_RESULT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-ex-result.xml") +#define VC_RUNTIME_INFO_EX_RESULT tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc/vc-ex-result.xml") -#define VC_RUNTIME_INFO_CLIENT tzplatform_mkpath(TZ_USER_HOME, "share/voice/vc/vc-client-info.xml") +#define VC_RUNTIME_INFO_CLIENT tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc/vc-client-info.xml") #define VC_FEATURE_PATH "tizen.org/feature/speech.control" #define VC_MIC_FEATURE_PATH "tizen.org/feature/microphone" -- 2.7.4 From ac43f202b9a5b61d2dbb44c98bdf785929c609e9 Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Fri, 23 Oct 2015 20:00:32 +0900 Subject: [PATCH 05/16] Fix lib path for 64bit Change-Id: Ib8183f9d0f6182ab5aa5d6052f8d2ea777af2e9d --- CMakeLists.txt | 4 ++++ common/vc_defs.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d978245..67782d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,10 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") SET(VERSION 0.2.10) +IF (LIBDIR MATCHES "/usr/lib64") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIB64") +ENDIF (LIBDIR) + # pkg config tool INCLUDE(FindPkgConfig) diff --git a/common/vc_defs.h b/common/vc_defs.h index c591038..5dd3300 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -145,7 +145,11 @@ extern "C" { #define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice") #define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc-config.xml") +#ifdef LIB64 +#define VC_DEFAULT_ENGINE_INFO "/usr/lib64/voice/vc/1.0/engine-info" +#else #define VC_DEFAULT_ENGINE_INFO "/usr/lib/voice/vc/1.0/engine-info" +#endif #define VC_NO_FOREGROUND_PID 0 -- 2.7.4 From 2ff4caed6d17ce3c1ea0bf1352fe05112dbd3469 Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Tue, 27 Oct 2015 21:17:40 +0900 Subject: [PATCH 06/16] Fix dbus bug about conn block Change-Id: I0deb6ab7bc797b31aba8bf10a2b1108a112982d1 --- CMakeLists.txt | 6 ++--- client/vc_mgr_dbus.c | 4 +-- common/vc_defs.h | 6 +---- org.tizen.voice.vcserver.service | 1 - packaging/voice-control.spec | 1 + server/vcd_dbus.c | 5 ++-- vc-server.conf | 53 ++-------------------------------------- 7 files changed, 12 insertions(+), 64 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67782d9..46927e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") SET(VERSION 0.2.10) -IF (LIBDIR MATCHES "/usr/lib64") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIB64") -ENDIF (LIBDIR) +ADD_DEFINITIONS("-DVOICE_LIBDIR=\"${LIBDIR}\"") # pkg config tool INCLUDE(FindPkgConfig) @@ -59,3 +57,5 @@ ADD_SUBDIRECTORY(server) INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION /usr/share/voice/vc/) INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.vcserver.service DESTINATION /usr/share/dbus-1/services) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-server.conf DESTINATION /etc/dbus-1/session.d) \ No newline at end of file diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 9fc3a09..f25cc8a 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -428,7 +428,7 @@ int vc_mgr_dbus_open_connection() dbus_error_init(&err); /* connect to the DBUS system bus, and check for errors */ - g_m_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); + 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); @@ -441,7 +441,7 @@ int vc_mgr_dbus_open_connection() } /* connect to the DBUS system bus, and check for errors */ - g_m_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); + 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); diff --git a/common/vc_defs.h b/common/vc_defs.h index 5dd3300..79e15b9 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -145,11 +145,7 @@ extern "C" { #define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice") #define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc-config.xml") -#ifdef LIB64 -#define VC_DEFAULT_ENGINE_INFO "/usr/lib64/voice/vc/1.0/engine-info" -#else -#define VC_DEFAULT_ENGINE_INFO "/usr/lib/voice/vc/1.0/engine-info" -#endif +#define VC_DEFAULT_ENGINE_INFO VOICE_LIBDIR"/voice/vc/1.0/engine-info" #define VC_NO_FOREGROUND_PID 0 diff --git a/org.tizen.voice.vcserver.service b/org.tizen.voice.vcserver.service index 6fd1b9b..a6f1e01 100644 --- a/org.tizen.voice.vcserver.service +++ b/org.tizen.voice.vcserver.service @@ -1,4 +1,3 @@ [D-BUS Service] Name=org.tizen.voice.vcserver Exec=/usr/bin/vc-daemon - diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 575da96..8ebf9da 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -111,6 +111,7 @@ mkdir -p /usr/share/voice/vc %{_libdir}/libvc_manager.so %{_bindir}/vc-daemon /usr/share/dbus-1/services/org.tizen.voice* +/etc/dbus-1/session.d/vc-server.conf /usr/share/voice/vc/vc-config.xml /usr/share/license/%{name} diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 49f5fa7..0b03140 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -174,6 +174,7 @@ int vcdc_send_set_volume(int manger_pid, float volume) if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); + dbus_message_unref(msg); return -1; } else { SLOG(LOG_DEBUG, TAG_VCD, "<<<< Send set volume : pid(%d), volume(%f)", manger_pid, volume); @@ -528,7 +529,7 @@ int vcd_dbus_open_connection() int ret; /* Create connection for sender */ - g_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); + 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); @@ -541,7 +542,7 @@ int vcd_dbus_open_connection() } /* connect to the bus and check for errors */ - g_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); + 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); diff --git a/vc-server.conf b/vc-server.conf index ded4aef..58c306e 100644 --- a/vc-server.conf +++ b/vc-server.conf @@ -3,95 +3,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- 2.7.4 From c035e7803a9a055221d17a86be36fd130272df1a Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 23 Dec 2015 08:46:03 +0900 Subject: [PATCH 07/16] modify files according to coding rule Change-Id: I8f68082c501d3b6b5a0d9562af2d8e458e59bc28 Signed-off-by: Wonnam Jang --- client/vc_dbus.c | 5 ++--- client/vc_mgr_dbus.c | 18 ++++++------------ client/vc_widget.c | 3 +-- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index bcf3964..8fdde2a 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -138,8 +138,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle 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 { + } else { SLOG(LOG_DEBUG, TAG_VCC, "<<<< vc Get Error message : pid(%d), reason(%d), msg(%s)", pid, reason, err_msg); __vc_cb_error(pid, reason); } @@ -147,7 +146,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_VCC, "====="); SLOG(LOG_DEBUG, TAG_VCC, " "); } /* VCD_METHOD_ERROR */ - + else { SLOG(LOG_DEBUG, TAG_VCC, "Message is NOT valid"); dbus_message_unref(msg); diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 9fc3a09..ae38429 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -89,8 +89,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd if (pid > 0) { SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr get hello : pid(%d) ", pid); response = 1; - } - else { + } else { SLOG(LOG_ERROR, TAG_VCM, "<<<< vc mgr get hello : invalid pid "); } @@ -107,8 +106,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd dbus_connection_flush(g_m_conn_listener); dbus_message_unref(reply); - } - else { + } else { SLOG(LOG_ERROR, TAG_VCM, ">>>> vc mgr get hello : fail to create reply message"); } @@ -219,8 +217,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd 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 { + } else { SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr request auth enable : pid(%d)", pid); ret = __vc_mgr_request_auth_enable(pid); } @@ -238,8 +235,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc mgr request auth enable : ret(%d)", ret); dbus_connection_flush(g_m_conn_listener); dbus_message_unref(reply); - } - else { + } else { SLOG(LOG_ERROR, TAG_VCM, ">>>> vc mgr request auth enable : fail to create reply message"); } @@ -259,8 +255,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd 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 { + } else { SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr request auth disable : pid(%d)", pid); ret = __vc_mgr_request_auth_disable(pid); } @@ -278,8 +273,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc mgr request auth disable : ret(%d)", ret); dbus_connection_flush(g_m_conn_listener); dbus_message_unref(reply); - } - else { + } else { SLOG(LOG_ERROR, TAG_VCM, ">>>> vc mgr request auth disable : fail to create reply message"); } diff --git a/client/vc_widget.c b/client/vc_widget.c index e8ae87b..ee7c4f2 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1114,8 +1114,7 @@ int __vc_widget_cb_service_state(int state) callback((vc_service_state_e)before_state, (vc_service_state_e)current_state, service_user_data); vc_widget_client_not_use_callback(g_vc_w); SLOG(LOG_DEBUG, TAG_VCW, "Service state changed callback is called"); - } - else { + } else { SLOG(LOG_WARN, TAG_VCW, "[WARNING] Service state changed callback is null"); } -- 2.7.4 From afa1a6d8e4fab41a10e05d9601e1eb948b9316e4 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Fri, 15 Jan 2016 13:41:59 +0900 Subject: [PATCH 08/16] update doxygen correctly Change-Id: I5b7cbf8f85bec55888a565434b337be86a436398 Signed-off-by: Wonnam Jang --- doc/uix_vc_doc.h | 4 ++-- include/voice_control.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/uix_vc_doc.h b/doc/uix_vc_doc.h index ac100b1..5cb9861 100644 --- a/doc/uix_vc_doc.h +++ b/doc/uix_vc_doc.h @@ -173,7 +173,7 @@ * * * - * @section CAPI_UIX_VOICE_CONTROL_MODULE Related Features + * @section CAPI_UIX_VOICE_CONTROL_MODULE_FEATURES Related Features * This API is related with the following features:
* - http://tizen.org/feature/microphone
* - http://tizen.org/feature/speech.control
@@ -181,7 +181,7 @@ * It is recommended to design feature related codes in your application for reliability.
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.
* To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
- * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature Element. * */ diff --git a/include/voice_control.h b/include/voice_control.h index b751639..8e7b5f3 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -221,7 +221,7 @@ int vc_get_state(vc_state_e* state); * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported * -* @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. +* @pre The state should be #VC_STATE_READY. * * @see vc_request_start() * @see vc_request_stop() -- 2.7.4 From 64f06696c4576cec051b1242bb0cff68ff1ee691 Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Wed, 2 Mar 2016 11:13:52 +0900 Subject: [PATCH 09/16] Remove privilege-control dependency Change-Id: I8466b870f6cea04057ba3380a248212cbf9ab252 --- CMakeLists.txt | 4 ++-- packaging/voice-control.spec | 1 - server/vcd_main.c | 7 ------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46927e8..44ce6f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED aul capi-base-common capi-media-audio-io capi-media-sound-manager capi-network-bluetooth capi-system-info - dbus-1 dlog ecore glib-2.0 libprivilege-control libxml-2.0 vconf + dbus-1 dlog ecore glib-2.0 libxml-2.0 vconf ) ## API ## @@ -58,4 +58,4 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION /usr/share/voice/vc/ INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.vcserver.service DESTINATION /usr/share/dbus-1/services) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-server.conf DESTINATION /etc/dbus-1/session.d) \ No newline at end of file +INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-server.conf DESTINATION /etc/dbus-1/session.d) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 8ebf9da..d983658 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -20,7 +20,6 @@ BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(libprivilege-control) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(vconf) diff --git a/server/vcd_main.c b/server/vcd_main.c index be92c7e..5eb0b5a 100644 --- a/server/vcd_main.c +++ b/server/vcd_main.c @@ -19,8 +19,6 @@ #include "vcd_main.h" #include "vcd_server.h" -#include - #define CLIENT_CLEAN_UP_TIME 500 static Ecore_Timer* g_check_client_timer = NULL; @@ -36,11 +34,6 @@ int main(int argc, char** argv) return -1; } - if (0 == setuid(0)) { - /* daemon has root previlege */ - perm_app_set_privilege("voice-control", NULL, NULL); - } - if (0 != vcd_dbus_open_connection()) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); return EXIT_FAILURE; -- 2.7.4 From df9f7583186d41ebeb54d12ddfc221fda4131b63 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Tue, 29 Mar 2016 11:45:58 +0900 Subject: [PATCH 10/16] updates codes to sync with the latest 2.4 spin code Change-Id: Iddda19f807a21ba429033a04bcf1c3fd3fa87934 Signed-off-by: Wonnam Jang --- CMakeLists.txt | 4 +- changelog | 1 + client/vc.c | 95 +++++++++++++++-- client/vc_client.c | 32 +++++- client/vc_client.h | 4 + client/vc_dbus.c | 136 +++++++++++++++++++++---- client/vc_dbus.h | 2 + client/vc_mgr.c | 87 +++++++++------- client/vc_mgr_client.c | 38 ++++++- client/vc_mgr_client.h | 3 + client/vc_mgr_dbus.c | 81 +++++++++++---- client/vc_mgr_dbus.h | 2 +- client/vc_setting.c | 61 ++++++++++- client/vc_widget.c | 9 +- client/vc_widget_dbus.c | 120 ++++++++++++++++++++-- client/vc_widget_dbus.h | 2 + common/vc_command.c | 6 ++ common/vc_config_mgr.c | 185 ---------------------------------- common/vc_config_mgr.h | 10 -- common/vc_config_parser.c | 8 +- common/vc_defs.h | 7 +- common/vc_info_parser.c | 11 +- include/voice_control_manager.h | 30 +++++- include/voice_control_setting.h | 52 +++++++++- packaging/voice-control.spec | 4 +- server/vcd_config.c | 36 +++---- server/vcd_config.h | 2 + server/vcd_dbus.c | 218 ++++++++++++++++++++++++---------------- server/vcd_dbus_server.c | 34 ++++++- server/vcd_dbus_server.h | 2 + server/vcd_main.c | 2 +- server/vcd_recorder.c | 1 - server/vcd_server.c | 216 +++++++++++++++++++++++++++++++++++++-- server/vcd_server.h | 8 +- 34 files changed, 1066 insertions(+), 443 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ce6f8..1158e48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED aul capi-base-common capi-media-audio-io capi-media-sound-manager capi-network-bluetooth capi-system-info - dbus-1 dlog ecore glib-2.0 libxml-2.0 vconf + dbus-1 dlog ecore glib-2.0 libtzplatform-config libxml-2.0 vconf ) ## API ## @@ -54,7 +54,7 @@ ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(server) ## config ## -INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION /usr/share/voice/vc/) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION ${LIBDIR}/voice/vc/1.0) INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.vcserver.service DESTINATION /usr/share/dbus-1/services) diff --git a/changelog b/changelog index 423a38d..9c9f3ee 100644 --- a/changelog +++ b/changelog @@ -7,6 +7,7 @@ voice-control (0.2.9) -- Mon, 6 Jul 2015 * Update daemon start by dbus activation (Dongyeol Lee ) * Add audio header and Fix volume data (Kwangyoun Kim ) * Update file IPC for service state to dbus IPC (Dongyeol Lee ) + * Update file IPC for foreground app to dbus IPC (Dongyeol Lee ) voice-control (0.2.8) -- Thu, 18 Jun 2015 diff --git a/client/vc.c b/client/vc.c index 1cad371..2379dfc 100644 --- a/client/vc.c +++ b/client/vc.c @@ -61,7 +61,13 @@ static int __vc_get_feature_enabled() } g_feature_enabled = 1; + } else { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; } + } else { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; } } @@ -145,6 +151,67 @@ static Eina_Bool __notify_auth_changed_cb(void *data) return EINA_FALSE; } +static int __vc_app_state_changed_cb(int app_state, void *data) +{ + int ret = -1; + SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] app state changed"); + + /* Set current pid */ + if (STATUS_VISIBLE == app_state) { + SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground"); + ret = vc_dbus_set_foreground(getpid(), true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); + } + + ret = vc_client_set_is_foreground(g_vc, true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret); + } + + /* set authority valid */ + vc_auth_state_e state = VC_AUTH_STATE_NONE; + if (0 != vc_client_get_auth_state(g_vc, &state)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); + } + if (VC_AUTH_STATE_INVALID == state) { + vc_client_set_auth_state(g_vc, VC_AUTH_STATE_VALID); + + /* notify auth changed cb */ + ecore_timer_add(0, __notify_auth_changed_cb, NULL); + } + } else if (STATUS_BG == app_state) { + SLOG(LOG_DEBUG, TAG_VCC, "===== Set background"); + ret = vc_dbus_set_foreground(getpid(), false); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (false) : %d", ret); + } + + ret = vc_client_set_is_foreground(g_vc, false); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (false) : %d", ret); + } + + /* set authority valid */ + vc_auth_state_e state = VC_AUTH_STATE_NONE; + if (0 != vc_client_get_auth_state(g_vc, &state)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); + } + if (VC_AUTH_STATE_VALID == state) { + vc_client_set_auth_state(g_vc, VC_AUTH_STATE_INVALID); + + /* notify authority changed cb */ + ecore_timer_add(0, __notify_auth_changed_cb, NULL); + } + } else { + SLOG(LOG_DEBUG, TAG_VCC, "===== App state is NOT valid"); + } + + SLOG(LOG_DEBUG, TAG_VCC, "====="); + SLOG(LOG_DEBUG, TAG_VCC, " "); + + return 0; +} int vc_initialize(void) { @@ -400,8 +467,12 @@ static Eina_Bool __vc_connect_daemon(void *data) #if 0 g_focus_in_hander = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, __vc_x_event_window_focus_in, NULL); g_focus_out_hander = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, __vc_x_event_window_focus_out, NULL); +#else + ret = aul_add_status_local_cb(__vc_app_state_changed_cb, NULL); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set app stae changed callback"); + } #endif - vc_client_set_client_state(g_vc, VC_STATE_READY); ecore_timer_add(0, __vc_notify_state_changed, g_vc); @@ -610,6 +681,13 @@ int vc_get_service_state(vc_service_state_e* state) return VC_ERROR_INVALID_STATE; } + if (VC_STATE_READY != temp) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); + SLOG(LOG_DEBUG, TAG_VCC, "====="); + SLOG(LOG_DEBUG, TAG_VCC, " "); + return VC_ERROR_INVALID_STATE; + } + /* get service state */ vc_service_state_e service_state; if (0 != vc_client_get_service_state(g_vc, &service_state)) { @@ -1281,13 +1359,8 @@ static Eina_Bool __vc_notify_result(void *data) return EINA_FALSE; } -void __vc_cb_result(int pid) +void __vc_cb_result(void) { - if (0 != vc_client_get_handle(pid, &g_vc)) { - SLOG(LOG_ERROR, TAG_VCC, "Handle is not valid : pid(%d)", pid); - return; - } - ecore_timer_add(0, __vc_notify_result, NULL); return; @@ -1610,13 +1683,13 @@ int vc_auth_enable(void) } /* set authority into handle */ - int fg_pid = -1; - if (0 != vc_config_mgr_get_foreground(&fg_pid)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get foreground"); + bool is_foreground = false; + if (0 != vc_client_get_is_foreground(g_vc, &is_foreground)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get is_foreground"); return VC_ERROR_OPERATION_FAILED; } - if (g_vc->handle == fg_pid) { + if (is_foreground) { auth_state = VC_AUTH_STATE_VALID; } else { auth_state = VC_AUTH_STATE_INVALID; diff --git a/client/vc_client.c b/client/vc_client.c index 6e96189..5f2d6b3 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -60,6 +60,9 @@ typedef struct { void* auth_state_changed_user_data; int mgr_pid; + + /* is foreground */ + bool is_foreground; } vc_client_s; /* client list */ @@ -132,7 +135,7 @@ int vc_client_create(vc_h* vc) client->exclusive_cmd = false; #endif - client->service_state = -1; + client->service_state = VC_RUNTIME_INFO_NO_FOREGROUND; client->before_state = VC_STATE_INITIALIZED; client->current_state = VC_STATE_INITIALIZED; @@ -145,6 +148,8 @@ int vc_client_create(vc_h* vc) client->auth_state_changed_cb = NULL; client->auth_state_changed_user_data = NULL; + client->is_foreground = false; + g_client_list = g_slist_append(g_client_list, client); *vc = temp; @@ -498,6 +503,31 @@ int vc_client_get_xid(vc_h vc, int* xid) return 0; } +int vc_client_set_is_foreground(vc_h vc, bool value) +{ + vc_client_s* client = __client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + client->is_foreground = value; + return 0; +} + +int vc_client_get_is_foreground(vc_h vc, bool* value) +{ + vc_client_s* client = __client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + *value = client->is_foreground; + + return 0; +} + #if 0 int vc_client_set_exclusive_cmd(vc_h vc, bool value) { diff --git a/client/vc_client.h b/client/vc_client.h index 948228f..0067ec3 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -84,6 +84,10 @@ int vc_client_set_xid(vc_h vc, int xid); int vc_client_get_xid(vc_h vc, int* xid); +int vc_client_set_is_foreground(vc_h vc, bool value); + +int vc_client_get_is_foreground(vc_h vc, bool* value); + #if 0 int vc_client_set_exclusive_cmd(vc_h vc, bool value); diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 8fdde2a..8519d42 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -29,7 +29,7 @@ static DBusConnection* g_conn_listener = NULL; extern int __vc_cb_error(int pid, int reason); -extern void __vc_cb_result(int pid); +extern void __vc_cb_result(); extern int __vc_cb_service_state(int state); @@ -110,20 +110,17 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle } /* VCD_METHOD_SET_SERVICE_STATE */ - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_RESULT)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_RESULT)) { SLOG(LOG_DEBUG, TAG_VCC, "===== Get Client Result"); - int pid = 0; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - __vc_cb_result(pid); + __vc_cb_result(); SLOG(LOG_DEBUG, TAG_VCC, "====="); SLOG(LOG_DEBUG, TAG_VCC, " "); } /* VCD_METHOD_RESULT */ - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCC, "===== Get Error"); int pid; int reason; @@ -168,12 +165,13 @@ int vc_dbus_open_connection() } DBusError err; + int ret; /* initialise the error value */ dbus_error_init(&err); /* connect to the DBUS system bus, and check for errors */ - g_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); + 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); @@ -185,7 +183,7 @@ int vc_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } - g_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); + 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); @@ -197,6 +195,27 @@ int vc_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } + 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); + dbus_error_free(&err); + } + + if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { + SLOG(LOG_ERROR, TAG_VCC, "fail dbus_bus_request_name()"); + return -2; + } + if (NULL != g_fd_handler) { SLOG(LOG_WARN, TAG_VCC, "The handler already exists."); return 0; @@ -242,6 +261,21 @@ int vc_dbus_close_connection() g_fd_handler = NULL; } + 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); + dbus_error_free(&err); + } + + dbus_connection_close(g_conn_sender); + dbus_connection_close(g_conn_listener); g_conn_sender = NULL; g_conn_listener = NULL; @@ -626,6 +660,70 @@ int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type) return result; } +int vc_dbus_set_foreground(int pid, bool value) +{ + 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"); + 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"); + 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"); + 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"); + return VC_ERROR_OPERATION_FAILED; + } + + dbus_connection_flush(g_conn_sender); + + dbus_message_unref(msg); + + return 0; +} + #if 0 int vc_dbus_request_start(int pid, int silence) { @@ -826,9 +924,9 @@ int vc_dbus_request_auth_enable(int pid, int mgr_pid) char object_path[64] = {0,}; char target_if_name[128] = {0,}; - snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); + 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", VC_MANAGER_SERVICE_INTERFACE); + 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( @@ -896,9 +994,9 @@ int vc_dbus_request_auth_disable(int pid, int mgr_pid) char object_path[64] = {0,}; char target_if_name[128] = {0,}; - snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); + 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", VC_MANAGER_SERVICE_INTERFACE); + 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( @@ -966,9 +1064,9 @@ int vc_dbus_request_auth_start(int pid, int mgr_pid) char object_path[64] = {0,}; char target_if_name[128] = {0,}; - snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); + 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", VC_MANAGER_SERVICE_INTERFACE); + 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( @@ -1038,9 +1136,9 @@ int vc_dbus_request_auth_stop(int pid, int mgr_pid) char object_path[64] = {0,}; char target_if_name[128] = {0,}; - snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); + 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", VC_MANAGER_SERVICE_INTERFACE); + 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( @@ -1108,9 +1206,9 @@ int vc_dbus_request_auth_cancel(int pid, int mgr_pid) char object_path[64] = {0,}; char target_if_name[128] = {0,}; - snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); + 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", VC_MANAGER_SERVICE_INTERFACE); + 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( diff --git a/client/vc_dbus.h b/client/vc_dbus.h index 4d9e0cc..7a6f811 100644 --- a/client/vc_dbus.h +++ b/client/vc_dbus.h @@ -40,6 +40,8 @@ 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); + #if 0 int vc_dbus_request_start(int pid, int silence); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 70a6d2f..cdeeee5 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -82,32 +82,6 @@ static void __vc_mgr_lang_changed_cb(const char* before_lang, const char* curren return; } -static void __vc_mgr_foreground_changed_cb(int previous, int current) -{ - SLOG(LOG_DEBUG, TAG_VCM, "Foreground changed : Before(%d) Current(%d)", previous, current); - - /* get authorized valid app */ - int pid; - if (0 != vc_mgr_client_get_valid_authorized_client(g_vc_m, &pid)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get authorized valid app"); - return; - } - - /* compare & set valid */ - if (current != pid) { - SLOG(LOG_DEBUG, TAG_VCM, "Authority(%d) changed to invalid", pid); - - /* set authorized valid */ - if (true == vc_mgr_client_is_authorized_client(g_vc_m, current)) { - SLOG(LOG_DEBUG, TAG_VCM, "Authority(%d) change to valid", current); - vc_mgr_client_set_valid_authorized_client(g_vc_m, current); - } else { - SLOG(LOG_DEBUG, TAG_VCM, "No valid Authority"); - vc_mgr_client_set_valid_authorized_client(g_vc_m, -1); - } - } -} - int vc_mgr_initialize() { SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Initialize"); @@ -143,8 +117,6 @@ int vc_mgr_initialize() return VC_ERROR_OPERATION_FAILED; } - ret = vc_config_mgr_set_foreground_cb(g_vc_m->handle + VC_MANAGER_CONFIG_HANDLE, __vc_mgr_foreground_changed_cb); - SLOG(LOG_DEBUG, TAG_VCM, "[Success] pid(%d)", g_vc_m->handle); SLOG(LOG_DEBUG, TAG_VCM, "====="); @@ -229,7 +201,8 @@ static Eina_Bool __vc_mgr_connect_daemon(void *data) /* request initialization */ int ret = -1; int service_state = 0; - ret = vc_mgr_dbus_request_initialize(g_vc_m->handle, &service_state); + int foreground = VC_RUNTIME_INFO_NO_FOREGROUND; + ret = vc_mgr_dbus_request_initialize(g_vc_m->handle, &service_state, &foreground); if (VC_ERROR_ENGINE_NOT_FOUND == ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize : %s", __vc_mgr_get_error_code(ret)); @@ -251,6 +224,9 @@ static Eina_Bool __vc_mgr_connect_daemon(void *data) /* Set service state */ vc_mgr_client_set_service_state(g_vc_m, (vc_service_state_e)service_state); + /* Set foreground */ + vc_mgr_client_set_foreground(g_vc_m, foreground, true); + SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Connected daemon"); vc_mgr_client_set_client_state(g_vc_m, VC_STATE_READY); @@ -906,7 +882,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) int ret = -1; /* Get foreground pid */ - if (0 != vc_config_mgr_get_foreground(&fg_pid)) { + if (0 != vc_mgr_client_get_foreground(g_vc_m, &fg_pid)) { /* There is no foreground app for voice control */ SLOG(LOG_WARN, TAG_VCM, "[Manager WARNING] No foreground pid for voice control"); } else { @@ -1102,7 +1078,7 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) return 0; } -int vc_mgr_start(bool stop_by_silence, bool exclusive_command_option) +int vc_mgr_start(bool exclusive_command_option) { SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Request start"); @@ -1141,12 +1117,10 @@ int vc_mgr_start(bool stop_by_silence, bool exclusive_command_option) int ret; int count = 0; - vc_recognition_mode_e recognition_mode; - - if (0 == stop_by_silence) - recognition_mode = VC_RECOGNITION_MODE_MANUAL; - else - vc_mgr_get_recognition_mode(&recognition_mode); + 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"); + } /* Request */ ret = -1; @@ -1329,6 +1303,41 @@ int vc_mgr_get_recording_volume(float* volume) return 0; } +int __vc_mgr_cb_set_foreground(int pid, bool value) +{ + vc_mgr_client_set_foreground(g_vc_m, pid, value); + + /* get authorized valid app */ + int tmp_pid; + if (0 != vc_mgr_client_get_valid_authorized_client(g_vc_m, &tmp_pid)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get authorized valid app"); + return VC_ERROR_INVALID_PARAMETER; + } + + if (true == value) { + /* compare & set valid */ + if (tmp_pid != pid) { + SLOG(LOG_DEBUG, TAG_VCM, "Authority(%d) changed to invalid", tmp_pid); + + /* set authorized valid */ + if (true == vc_mgr_client_is_authorized_client(g_vc_m, pid)) { + SLOG(LOG_DEBUG, TAG_VCM, "Authority(%d) change to valid", pid); + vc_mgr_client_set_valid_authorized_client(g_vc_m, pid); + } else { + SLOG(LOG_DEBUG, TAG_VCM, "No valid Authority"); + vc_mgr_client_set_valid_authorized_client(g_vc_m, -1); + } + } + } else { + if (tmp_pid == pid) { + SLOG(LOG_DEBUG, TAG_VCM, "Authority(%d) changed to invalid", tmp_pid); + vc_mgr_client_set_valid_authorized_client(g_vc_m, -1); + } + } + + return 0; +} + int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) { SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Select result"); @@ -2017,7 +2026,7 @@ int __vc_mgr_request_auth_enable(int pid) /* foreground check */ int fore_pid = 0; - if (0 != vc_config_mgr_get_foreground(&fore_pid)) { + if (0 != vc_mgr_client_get_foreground(g_vc_m, &fore_pid)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get foreground"); return VC_ERROR_OPERATION_FAILED; } @@ -2063,7 +2072,7 @@ static Eina_Bool __request_auth_start(void* data) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set start by client"); } - if (0 != vc_mgr_start(true, false)) { + if (0 != vc_mgr_start(false)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Request start is failed"); /* TODO - Error handling? */ } diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index 64ed2d5..f0855db 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -78,6 +78,9 @@ typedef struct { GSList* authorized_client_list; int valid_authorized_pid; bool start_by_client; + + /* foreground pid */ + int foreground_pid; } vc_mgr_client_s; typedef struct { @@ -179,6 +182,8 @@ int vc_mgr_client_create(vc_h* vc) client->valid_authorized_pid = -1; client->start_by_client = false; + client->foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; + g_mgr_client_list = g_slist_append(g_mgr_client_list, client); *vc = temp; @@ -747,7 +752,7 @@ int vc_mgr_client_set_recognition_mode(vc_h vc, vc_recognition_mode_e mode) int vc_mgr_client_get_recognition_mode(vc_h vc, vc_recognition_mode_e* mode) { - if (NULL == mode) { + if (NULL == mode) { return -1; } @@ -761,6 +766,37 @@ int vc_mgr_client_get_recognition_mode(vc_h vc, vc_recognition_mode_e* mode) return 0; } +int vc_mgr_client_set_foreground(vc_h vc, int pid, bool value) +{ + vc_mgr_client_s* client = __mgr_client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + if (true == value) { + client->foreground_pid = pid; + } else { + if (pid == client->foreground_pid) { + client->foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; + } + } + + return 0; +} + +int vc_mgr_client_get_foreground(vc_h vc, int* pid) +{ + vc_mgr_client_s* client = __mgr_client_get(vc); + + /* check handle */ + if (NULL == client) + return VC_ERROR_INVALID_PARAMETER; + + *pid = client->foreground_pid; + return 0; +} + /* utils */ int vc_mgr_client_get_count() { diff --git a/client/vc_mgr_client.h b/client/vc_mgr_client.h index 962d667..e69fed9 100644 --- a/client/vc_mgr_client.h +++ b/client/vc_mgr_client.h @@ -110,6 +110,9 @@ int vc_mgr_client_set_recognition_mode(vc_h vc, vc_recognition_mode_e mode); int vc_mgr_client_get_recognition_mode(vc_h vc, vc_recognition_mode_e* mode); +int vc_mgr_client_set_foreground(vc_h vc, int pid, bool value); + +int vc_mgr_client_get_foreground(vc_h vc, int* pid); /* utils */ int vc_mgr_client_get_count(); diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 164e1a4..5a35278 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -28,6 +28,8 @@ static Ecore_Fd_Handler* g_m_fd_handler = NULL; static DBusConnection* g_m_conn_sender = NULL; static DBusConnection* g_m_conn_listener = NULL; +static int g_volume_count = 0; + extern void __vc_mgr_cb_all_result(vc_result_type_e type); @@ -41,6 +43,8 @@ extern int __vc_mgr_cb_set_volume(float volume); extern int __vc_mgr_cb_service_state(int state); +extern int __vc_mgr_cb_set_foreground(int pid, bool value); + /* Authority */ extern int __vc_mgr_request_auth_enable(int pid); @@ -67,12 +71,12 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd break; } - SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Message is arrived"); + /* SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Message is arrived"); */ DBusError err; dbus_error_init(&err); - char if_name[64]; + char if_name[64] = {0, }; snprintf(if_name, 64, "%s", VC_MANAGER_SERVICE_INTERFACE); if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_HELLO)) { @@ -115,7 +119,6 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_METHOD_HELLO */ else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_SET_VOLUME)) { - /* SLOG(LOG_DEBUG, TAG_VCM, "===== Set volume"); */ float volume = 0; dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &volume, DBUS_TYPE_INVALID); @@ -125,11 +128,15 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd dbus_error_free(&err); } - SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr set volume : volume(%f)", volume); + if (10 == g_volume_count) { + SLOG(LOG_DEBUG, TAG_VCM, "===== Set volume"); + SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr set volume : volume(%f)", volume); + g_volume_count = 0; + } + __vc_mgr_cb_set_volume(volume); + g_volume_count++; - /* SLOG(LOG_DEBUG, TAG_VCM, "====="); */ - /* SLOG(LOG_DEBUG, TAG_VCM, " "); */ } /* VCD_MANAGER_METHOD_SET_VOLUME */ else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_SET_SERVICE_STATE)) { @@ -147,7 +154,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_SET_SERVICE_STATE */ - else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_SPEECH_DETECTED)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_SPEECH_DETECTED)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get Speech detected"); __vc_mgr_cb_speech_detected(); @@ -157,7 +164,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_SPEECH_DETECTED */ - else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_ALL_RESULT)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_ALL_RESULT)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get All Result"); int result_type = 0; @@ -170,7 +177,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_ALL_RESULT */ - else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_RESULT)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_RESULT)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get System Result"); __vc_mgr_cb_system_result(); @@ -180,7 +187,28 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_MANAGER_METHOD_RESULT */ - else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_ERROR)) { + else if (dbus_message_is_signal(msg, if_name, VCC_MANAGER_METHOD_SET_FOREGROUND)) { + SLOG(LOG_DEBUG, 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_DEBUG, 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, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + } /* VCC_MANAGER_METHOD_SET_FOREGROUND */ + + else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCM, "===== Get Error"); int pid; int reason; @@ -508,13 +536,22 @@ int vc_mgr_dbus_close_connection() g_m_fd_handler = NULL; } - dbus_bus_release_name(g_m_conn_listener, VC_MANAGER_SERVICE_NAME, &err); + 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); } + dbus_connection_close(g_m_conn_sender); + dbus_connection_close(g_m_conn_listener); + g_m_conn_sender = NULL; g_m_conn_listener = NULL; @@ -582,8 +619,7 @@ int vc_mgr_dbus_request_hello() return result; } - -int vc_mgr_dbus_request_initialize(int pid, int* service_state) +int vc_mgr_dbus_request_initialize(int pid, int* service_state, int* foreground) { DBusMessage* msg; @@ -619,9 +655,12 @@ int vc_mgr_dbus_request_initialize(int pid, int* service_state) } if (NULL != result_msg) { + int tmp_service_state = 0; + int tmp_foreground = 0; dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, service_state, + DBUS_TYPE_INT32, &tmp_service_state, + DBUS_TYPE_INT32, &tmp_foreground, DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { @@ -633,7 +672,10 @@ int vc_mgr_dbus_request_initialize(int pid, int* service_state) dbus_message_unref(result_msg); if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr initialize : result = %d, service state = %d", result, *service_state); + *service_state = tmp_service_state; + *foreground = tmp_foreground; + SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr initialize : result = %d, service state = %d, foreground = %d", + result, *service_state, *foreground); } else { SLOG(LOG_ERROR, TAG_VCM, "<<<< vc mgr initialize : result = %d", result); } @@ -1285,14 +1327,13 @@ static DBusMessage* __get_message(int pid, const char* method, int type) memset(target_if_name, '\0', 128); if (VC_COMMAND_TYPE_FOREGROUND == type || VC_COMMAND_TYPE_BACKGROUND == type) { - snprintf(service_name, 64, "%s", VC_CLIENT_SERVICE_NAME); + 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_NAME); - + snprintf(target_if_name, 128, "%s%d", VC_CLIENT_SERVICE_NAME, pid); } else if (VC_COMMAND_TYPE_WIDGET == type) { - snprintf(service_name, 64, "%s", VC_WIDGET_SERVICE_NAME); + 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); + snprintf(target_if_name, 128, "%s%d", VC_WIDGET_SERVICE_INTERFACE, pid); } else { return NULL; } diff --git a/client/vc_mgr_dbus.h b/client/vc_mgr_dbus.h index e583560..486bd72 100644 --- a/client/vc_mgr_dbus.h +++ b/client/vc_mgr_dbus.h @@ -30,7 +30,7 @@ int vc_mgr_dbus_close_connection(); int vc_mgr_dbus_request_hello(); -int vc_mgr_dbus_request_initialize(int pid, int* service_state); +int vc_mgr_dbus_request_initialize(int pid, int* service_state, int* foreground); int vc_mgr_dbus_request_finalize(int pid); diff --git a/client/vc_setting.c b/client/vc_setting.c index abcc54e..28de295 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -32,10 +32,13 @@ typedef enum { static vc_setting_state_e g_state = VC_SETTING_STATE_NONE; -static vc_setting_enabled_changed_cb g_callback; +static vc_setting_enabled_changed_cb g_callback = NULL; -static void* g_user_data; +static void* g_user_data = NULL; +static vc_setting_current_language_changed_cb g_lang_callback = NULL; + +static void* g_lang_user_data = NULL; const char* vc_tag() { @@ -45,6 +48,10 @@ const char* vc_tag() void __config_lang_changed_cb(const char* before_lang, const char* current_lang) { SLOG(LOG_DEBUG, TAG_VCS, "Lang changed : before(%s) current(%s)", before_lang, current_lang); + + if (NULL != g_lang_callback) { + g_lang_callback(before_lang, current_lang, g_lang_user_data); + } } void __vc_setting_state_changed_cb(int before_state, int current_state, void* user_data) @@ -380,4 +387,52 @@ int vc_setting_unset_enabled_changed_cb() SLOG(LOG_DEBUG, TAG_VCS, " "); return 0; -} \ No newline at end of file +} + +int vc_setting_set_current_language_changed_cb(vc_setting_current_language_changed_cb callback, void* user_data) +{ + 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, "====="); + SLOG(LOG_DEBUG, TAG_VCS, " "); + return VC_ERROR_INVALID_STATE; + } + + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); + SLOG(LOG_DEBUG, TAG_VCS, "====="); + SLOG(LOG_DEBUG, TAG_VCS, " "); + return VC_ERROR_INVALID_PARAMETER; + } + + g_lang_callback = callback; + g_lang_user_data = user_data; + + SLOG(LOG_DEBUG, TAG_VCS, "====="); + SLOG(LOG_DEBUG, TAG_VCS, " "); + + return 0; +} + +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, "====="); + SLOG(LOG_DEBUG, TAG_VCS, " "); + return VC_ERROR_INVALID_STATE; + } + + g_lang_callback = NULL; + g_lang_user_data = NULL; + + SLOG(LOG_DEBUG, TAG_VCS, "====="); + SLOG(LOG_DEBUG, TAG_VCS, " "); + + return 0; +} + diff --git a/client/vc_widget.c b/client/vc_widget.c index ee7c4f2..98ecd1e 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -476,7 +476,7 @@ int vc_widget_set_foreground(bool value) } SLOG(LOG_DEBUG, TAG_VCW, "Set foreground : pid(%d) value(%s)", getpid(), value ? "true" : "false"); - int ret = vc_config_mgr_set_foreground(getpid(), value); + int ret = vc_widget_dbus_set_foreground(getpid(), value); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground : %s", __vc_widget_get_error_code(ret)); @@ -934,13 +934,8 @@ static Eina_Bool __vc_widget_notify_result(void *data) return EINA_FALSE; } -void __vc_widget_cb_result(int pid) +void __vc_widget_cb_result() { - if (0 != vc_widget_client_get_handle(pid, &g_vc_w)) { - SLOG(LOG_ERROR, TAG_VCW, "Handle is not valid : pid(%d)", pid); - return; - } - ecore_timer_add(0, __vc_widget_notify_result, NULL); return; diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index 129b9b1..1ad9ff2 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -31,7 +31,7 @@ extern int __vc_widget_cb_error(int pid, int reason); extern void __vc_widget_cb_show_tooltip(int pid, bool show); -extern void __vc_widget_cb_result(int pid); +extern void __vc_widget_cb_result(); extern int __vc_widget_cb_service_state(int state); @@ -114,7 +114,7 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_WIDGET_METHOD_SET_SERVICE_STATE */ - else if (dbus_message_is_signal(msg, if_name, VCD_WIDGET_METHOD_SHOW_TOOLTIP)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_WIDGET_METHOD_SHOW_TOOLTIP)) { SLOG(LOG_DEBUG, TAG_VCW, "===== Show / Hide tooltip"); int pid = 0; int show = 0; @@ -140,13 +140,10 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCW, " "); } /* VCD_WIDGET_METHOD_SHOW_TOOLTIP */ - else if (dbus_message_is_signal(msg, if_name, VCD_WIDGET_METHOD_RESULT)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_WIDGET_METHOD_RESULT)) { SLOG(LOG_DEBUG, TAG_VCW, "===== Get widget result"); - int pid = 0; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - __vc_widget_cb_result(pid); + __vc_widget_cb_result(); /* reply = dbus_message_new_method_return(msg); @@ -169,7 +166,7 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_WIDGET_METHOD_RESULT */ - else if (dbus_message_is_signal(msg, if_name, VCD_WIDGET_METHOD_ERROR)) { + else if (dbus_message_is_method_call(msg, if_name, VCD_WIDGET_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCW, "===== Get widget error"); int pid; int reason; @@ -230,12 +227,13 @@ int vc_widget_dbus_open_connection() } DBusError err; + int ret; /* initialise the error value */ dbus_error_init(&err); /* connect to the DBUS system bus, and check for errors */ - g_w_conn_sender = dbus_bus_get(DBUS_BUS_SESSION, &err); + g_w_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "Dbus Connection Error (%s)", err.message); @@ -247,7 +245,7 @@ int vc_widget_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } - g_w_conn_listener = dbus_bus_get(DBUS_BUS_SESSION, &err); + g_w_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "Dbus Connection Error (%s)", err.message); @@ -259,6 +257,27 @@ int vc_widget_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } + int pid = getpid(); + + char service_name[64]; + memset(service_name, '\0', 64); + snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); + + SLOG(LOG_DEBUG, TAG_VCW, "service name is %s", service_name); + + /* register our name on the bus, and check for errors */ + ret = dbus_bus_request_name(g_w_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCW, "Name Error (%s)", err.message); + dbus_error_free(&err); + } + + if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { + SLOG(LOG_ERROR, TAG_VCW, "fail dbus_bus_request_name()"); + return -2; + } + if (NULL != g_w_fd_handler) { SLOG(LOG_WARN, TAG_VCW, "The handler already exists."); return 0; @@ -305,6 +324,22 @@ int vc_widget_dbus_close_connection() g_w_fd_handler = NULL; } + int pid = getpid(); + + char service_name[64]; + memset(service_name, '\0', 64); + snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); + + dbus_bus_release_name(g_w_conn_listener, service_name, &err); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } + + dbus_connection_close(g_w_conn_sender); + dbus_connection_close(g_w_conn_listener); + g_w_conn_sender = NULL; g_w_conn_listener = NULL; @@ -559,6 +594,71 @@ int vc_widget_dbus_request_start_recording(int pid, bool command) return result; } +int vc_widget_dbus_set_foreground(int pid, bool value) +{ + 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_VCW, ">>>> vc widget set foreground to manager : Fail to make message"); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCW, ">>>> vc widget 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_w_conn_sender, msg, NULL)) { + SLOG(LOG_ERROR, TAG_VCW, "[Dbus ERROR] Fail to Send"); + 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_VCW, ">>>> vc widget set foreground to daemon : Fail to make message"); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCW, ">>>> vc widget 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_w_conn_sender, msg, NULL)) { + SLOG(LOG_ERROR, TAG_VCW, "[Dbus ERROR] Fail to Send"); + return VC_ERROR_OPERATION_FAILED; + } + + dbus_connection_flush(g_w_conn_sender); + + dbus_message_unref(msg); + + return 0; +} + + int vc_widget_dbus_request_start(int pid, int silence) { DBusMessage* msg; diff --git a/client/vc_widget_dbus.h b/client/vc_widget_dbus.h index ddf22ac..00312dd 100644 --- a/client/vc_widget_dbus.h +++ b/client/vc_widget_dbus.h @@ -36,6 +36,8 @@ int vc_widget_dbus_request_finalize(int pid); int vc_widget_dbus_request_start_recording(int pid, bool command); +int vc_widget_dbus_set_foreground(int pid, bool value); + int vc_widget_dbus_request_start(int pid, int silence); diff --git a/common/vc_command.c b/common/vc_command.c index f4fb2ef..1925731 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -45,7 +45,13 @@ static int __vc_cmd_get_feature_enabled() } g_feature_enabled = 1; + } else { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; } + } else { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; } } diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 94974d3..c86ec92 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -38,7 +38,6 @@ typedef struct { int uid; vc_config_lang_changed_cb lang_cb; - vc_config_foreground_changed_cb foreground_cb; vc_config_enabled_cb enabled_cb; } vc_config_client_s; @@ -61,11 +60,6 @@ static Ecore_Fd_Handler* g_fd_handler_lang = NULL; static int g_fd_lang; static int g_wd_lang; -static int g_fore_ref_count; -static Ecore_Fd_Handler* g_fd_handler_fore = NULL; -static int g_fd_fore; -static int g_wd_fore; - int __vc_config_mgr_print_engine_info(); @@ -529,28 +523,9 @@ int vc_config_mgr_initialize(int uid) SLOG(LOG_WARN, vc_config_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid); __vc_config_mgr_print_client_info(); - return 0; } - if (0 != access(VC_CONFIG_BASE, F_OK)) { - if (0 != mkdir(VC_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to make directory : %s", VC_CONFIG_BASE); - return -1; - } else { - SLOG(LOG_DEBUG, vc_config_tag(), "Success to make directory : %s", VC_CONFIG_BASE); - } - } - - if (0 != access(VC_RUNTIME_INFO_ROOT, F_OK)) { - if (0 != mkdir(VC_RUNTIME_INFO_ROOT, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to make directory : %s", VC_RUNTIME_INFO_ROOT); - return -1; - } else { - SLOG(LOG_DEBUG, vc_config_tag(), "Success to make directory : %s", VC_RUNTIME_INFO_ROOT); - } - } - /* Get file name from default engine directory */ DIR *dp = NULL; int ret = -1; @@ -658,7 +633,6 @@ int vc_config_mgr_initialize(int uid) SLOG(LOG_DEBUG, vc_config_tag(), "Current foreground pid : %d", g_foreground_pid); g_lang_ref_count = 0; - g_fore_ref_count = 0; /* Register to detect display language change */ vconf_notify_key_changed(VCONFKEY_LANGSET, __vc_config_language_changed_cb, NULL); @@ -846,165 +820,6 @@ int vc_config_mgr_unset_lang_cb(int uid) return 0; } -Eina_Bool vc_config_mgr_inotify_foreground_cb(void* data, Ecore_Fd_Handler *fd_handler) -{ - SLOG(LOG_DEBUG, vc_config_tag(), "===== Foreground changed callback event"); - - int length; - struct inotify_event event; - memset(&event, '\0', sizeof(struct inotify_event)); - - length = read(g_fd_fore, &event, sizeof(struct inotify_event)); - if (0 > length) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Empty Inotify event"); - SLOG(LOG_DEBUG, vc_config_tag(), "====="); - SLOG(LOG_DEBUG, vc_config_tag(), " "); - return ECORE_CALLBACK_PASS_ON; - } - - if (IN_CLOSE_WRITE == event.mask) { - int foreground_pid = -1; - if (0 != vc_parser_get_foreground(&foreground_pid)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to get state"); - return ECORE_CALLBACK_PASS_ON; - } - - SLOG(LOG_DEBUG, vc_config_tag(), "foreground pid (%d)", foreground_pid); - - /* If foreground pid is changed */ - if (g_foreground_pid != foreground_pid) { - int previous_pid = g_foreground_pid; - g_foreground_pid = foreground_pid; - - GSList *iter = NULL; - vc_config_client_s* temp_client = NULL; - - /* Call all callbacks of client*/ - iter = g_slist_nth(g_config_client_list, 0); - - while (NULL != iter) { - temp_client = iter->data; - - if (NULL != temp_client) { - if (NULL != temp_client->foreground_cb) { - temp_client->foreground_cb(previous_pid, g_foreground_pid); - } - } - - iter = g_slist_next(iter); - } - } - } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Undefined event"); - } - - SLOG(LOG_DEBUG, vc_config_tag(), "====="); - SLOG(LOG_DEBUG, vc_config_tag(), " "); - - return ECORE_CALLBACK_PASS_ON; -} - -int __vc_config_mgr_register_foreground_event() -{ - if (0 == g_fore_ref_count) { - /* get file notification handler */ - int fd; - int wd; - - fd = inotify_init(); - if (fd < 0) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail get inotify fd"); - return -1; - } - g_fd_fore = fd; - - wd = inotify_add_watch(g_fd_fore, VC_RUNTIME_INFO_FOREGROUND, IN_CLOSE_WRITE); - g_wd_fore = wd; - - g_fd_handler_fore = ecore_main_fd_handler_add(g_fd_fore, ECORE_FD_READ, (Ecore_Fd_Cb)vc_config_mgr_inotify_foreground_cb, - NULL, NULL, NULL); - if (NULL == g_fd_handler_fore) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get handler for foreground"); - return -1; - } - } - g_fore_ref_count++; - - return 0; -} - -int __vc_config_mgr_unregister_foreground_event() -{ - if (0 == g_fore_ref_count) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Foreground ref count is 0"); - return VC_CONFIG_ERROR_INVALID_STATE; - } - - g_fore_ref_count--; - - if (0 == g_fore_ref_count) { - /* delete inotify variable */ - ecore_main_fd_handler_del(g_fd_handler_fore); - inotify_rm_watch(g_fd_fore, g_wd_fore); - close(g_fd_fore); - } - - return 0; -} - -int vc_config_mgr_set_foreground_cb(int uid, vc_config_foreground_changed_cb foreground_cb) -{ - if (NULL == foreground_cb) { - SLOG(LOG_ERROR, vc_config_tag(), "Foreground changed cb is NULL : uid(%d) ", uid); - return VC_CONFIG_ERROR_INVALID_PARAMETER; - } - - GSList *iter = NULL; - vc_config_client_s* temp_client = NULL; - - /* Call all callbacks of client*/ - iter = g_slist_nth(g_config_client_list, 0); - - while (NULL != iter) { - temp_client = iter->data; - - if (NULL != temp_client) { - if (uid == temp_client->uid) { - temp_client->foreground_cb = foreground_cb; - __vc_config_mgr_register_foreground_event(); - return VC_CONFIG_ERROR_NONE; - } - } - iter = g_slist_next(iter); - } - - return VC_CONFIG_ERROR_INVALID_PARAMETER; -} - -int vc_config_mgr_unset_foreground_cb(int uid) -{ - GSList *iter = NULL; - vc_config_client_s* temp_client = NULL; - - /* Call all callbacks of client*/ - iter = g_slist_nth(g_config_client_list, 0); - - while (NULL != iter) { - temp_client = iter->data; - - if (NULL != temp_client) { - if (uid == temp_client->uid) { - temp_client->foreground_cb = NULL; - __vc_config_mgr_unregister_foreground_event(); - return 0; - } - } - iter = g_slist_next(iter); - } - - return VC_CONFIG_ERROR_INVALID_PARAMETER; -} - int vc_config_mgr_set_enabled_cb(int uid, vc_config_enabled_cb enabled_cb) { if (NULL == enabled_cb) { diff --git a/common/vc_config_mgr.h b/common/vc_config_mgr.h index a1e7e82..b07d1d4 100644 --- a/common/vc_config_mgr.h +++ b/common/vc_config_mgr.h @@ -39,8 +39,6 @@ typedef enum { typedef void (*vc_config_lang_changed_cb)(const char* before_lang, const char* current_lang); -typedef void (*vc_config_foreground_changed_cb)(int previous, int current); - typedef void (*vc_config_enabled_cb)(bool enable); @@ -54,9 +52,6 @@ int vc_config_mgr_set_lang_cb(int uid, vc_config_lang_changed_cb lang_cb); int vc_config_mgr_unset_lang_cb(int uid); -int vc_config_mgr_set_foreground_cb(int uid, vc_config_foreground_changed_cb foreground_cb); - -int vc_config_mgr_unset_foreground_cb(int uid); int vc_config_mgr_set_enabled_cb(int uid, vc_config_enabled_cb enabled_cb); @@ -85,11 +80,6 @@ bool vc_config_check_default_language_is_valid(const char* language); int vc_config_convert_error_code(vc_config_error_e code); -int vc_config_mgr_set_foreground(int pid, bool value); - -int vc_config_mgr_get_foreground(int* pid); - - #ifdef __cplusplus } #endif diff --git a/common/vc_config_parser.c b/common/vc_config_parser.c index 5001a1f..f4c3456 100644 --- a/common/vc_config_parser.c +++ b/common/vc_config_parser.c @@ -56,9 +56,15 @@ static int __vc_config_parser_set_file_mode(const char* filename) if (0 > chmod(filename, 0666)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to change file mode"); - /* return -1; */ + return -1; } +#if 0 /*Does not need to change owner on Tizen 3.0*/ + if (0 > chown(filename, 5000, 5000)) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to change file owner"); + return -1; + } +#endif return 0; } diff --git a/common/vc_defs.h b/common/vc_defs.h index 79e15b9..53e1ba6 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -62,6 +62,7 @@ extern "C" { #define VC_METHOD_SET_EXCLUSIVE_CMD "vc_method_set_exclusive_cmd" #define VC_METHOD_SET_COMMAND "vc_method_set_command" #define VC_METHOD_UNSET_COMMAND "vc_method_unset_command" +#define VC_METHOD_SET_FOREGROUND "vc_method_set_foreground" #define VCD_METHOD_RESULT "vcd_method_result" #define VCD_METHOD_ERROR "vcd_method_error" @@ -133,6 +134,8 @@ extern "C" { #define VCD_MANAGER_METHOD_ERROR "vcd_manager_method_error" +#define VCC_MANAGER_METHOD_SET_FOREGROUND "vcd_manager_method_set_foreground" + /****************************************************************************************** * Defines for configuration @@ -140,7 +143,7 @@ extern "C" { #define VC_DAEMON_PATH "/usr/bin/vc-daemon" -#define VC_CONFIG_DEFAULT "/usr/share/voice/vc/vc-config.xml" +#define VC_CONFIG_DEFAULT VOICE_LIBDIR"/voice/vc/1.0/vc-config.xml" #define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice") #define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc-config.xml") @@ -166,6 +169,8 @@ extern "C" { #define VC_RUNTIME_INFO_CLIENT tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc/vc-client-info.xml") +#define VC_RUNTIME_INFO_NO_FOREGROUND -1 + #define VC_FEATURE_PATH "tizen.org/feature/speech.control" #define VC_MIC_FEATURE_PATH "tizen.org/feature/microphone" diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 44decad..321d924 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -77,8 +77,15 @@ static int __vc_info_parser_set_file_mode(const char* filename) if (0 > chmod(filename, 0666)) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to change file mode"); - /*return -1;*/ + return -1; + } + +#if 0 /*Does not need to change owner on Tizen 3.0*/ + if (0 > chown(filename, 5000, 5000)) { + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to change file owner"); + return -1; } +#endif return 0; } @@ -219,7 +226,7 @@ int vc_cmd_parser_save_file(int pid, vc_cmd_type_e type, GSList* cmd_list) if (0 < selected_count) { int ret = xmlSaveFormatFile(filepath, doc, 1); if (0 >= ret) { - SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Fail to save command file : %d", ret); + SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Fail to save command file : %d, filepath(%s)", ret, filepath); free(filepath); return -1; } diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index f6721f7..e1c96fa 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -39,6 +39,24 @@ extern "C" #define VC_AUDIO_TYPE_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio type */ /** +* @brief Definitions for foreground command type. +* @since_tizen 2.4 +*/ +#define VC_COMMAND_TYPE_FOREGROUND 1 + +/** +* @brief Definitions for background command type. +* @since_tizen 2.4 +*/ +#define VC_COMMAND_TYPE_BACKGROUND 2 + +/** +* @brief Definitions for widget command type. +* @since_tizen 2.4 +*/ +#define VC_COMMAND_TYPE_WIDGET 3 + +/** * @brief Definitions for system command type. * @since_tizen 2.4 */ @@ -228,7 +246,7 @@ int vc_mgr_get_state(vc_state_e* state); * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * -* @pre The state should NOT be #VC_SERVICE_STATE_NONE. +* @pre The state should be #VC_STATE_READY. * * @see vc_mgr_start() * @see vc_mgr_stop() @@ -373,7 +391,7 @@ int vc_mgr_get_audio_type(char** audio_id); /** * @brief Sets recognition mode. * -* @param[in] mode recognition mode (e.g. #VC_RECOGNITION_MODE_SILENCE_DETECTION_ONE_TURN is default value) +* @param[in] mode recognition mode (e.g. #VC_RECOGNITION_MODE_STOP_BY_SILENCE is default value) * * @return 0 on success, otherwise a negative error value * @retval #VC_ERROR_NONE Successful @@ -405,7 +423,9 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode); /** * @brief Starts recognition. * -* @param[in] stop_by_silence Silence detection option +* @remarks The default recognition mode is #VC_RECOGNITION_MODE_STOP_BY_SILENCE. \n +* If you want to use other mode, you can set mode with vc_mgr_set_recognition_mode(). +* * @param[in] exclusive_command_option Exclusive command option * * @return 0 on success, otherwise a negative error value @@ -421,8 +441,10 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode); * @see vc_mgr_stop() * @see vc_mgr_cancel() * @see vc_service_state_changed_cb() +* @see vc_mgr_set_recognition_mode() +* @see vc_mgr_get_recognition_mode() */ -int vc_mgr_start(bool stop_by_silence, bool exclusive_command_option); +int vc_mgr_start(bool exclusive_command_option); /** * @brief Stop recognition. diff --git a/include/voice_control_setting.h b/include/voice_control_setting.h index bd7127e..b5ea1e1 100644 --- a/include/voice_control_setting.h +++ b/include/voice_control_setting.h @@ -62,6 +62,19 @@ typedef void (*vc_setting_enabled_changed_cb)(bool enabled, void* user_data); */ typedef bool(*vc_setting_supported_language_cb)(const char* language, void* user_data); +/** +* @brief Called when default language is changed. +* @since_tizen 2.4 +* +* @param[in] previous Previous language +* @param[in] current Current language +* @param[in] user_data The user data passed from the callback registration function +* +* @pre An application registers this callback to detect changing mode. +* +* @see vc_setting_set_current_language_changed_cb() +*/ +typedef void (*vc_setting_current_language_changed_cb)(const char* previous, const char* current, void* user_data); /** * @brief Initialize voice control setting @@ -222,10 +235,10 @@ int vc_setting_set_enabled_changed_cb(vc_setting_enabled_changed_cb callback, vo * @brief Unsets the callback function. * * @return 0 on success, otherwise a negative error value -* @retval #VC_ELM_ERROR_NONE Successful -* @retval #VC_ELM_ERROR_INVALID_STATE Invalid state -* @retval #VC_ELM_ERROR_PERMISSION_DENIED Permission denied -* @retval #VC_ELM_ERROR_NOT_SUPPORTED Not supported +* @retval #VC_ERROR_NONE Success. +* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter. +* @retval #VC_ERROR_INVALID_STATE VC Not initialized. +* @retval #VC_ERROR_OPERATION_FAILED Operation failure. * * @pre vc_setting_initialize() should be successful. * @@ -233,6 +246,37 @@ int vc_setting_set_enabled_changed_cb(vc_setting_enabled_changed_cb callback, vo */ int vc_setting_unset_enabled_changed_cb(); +/** +* @brief Registers a callback function to be called when current language is changed. +* +* @param[in] callback Callback function to register +* @param[in] user_data The user data to be passed to the callback function +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_ERROR_NONE Success. +* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter. +* @retval #VC_ERROR_INVALID_STATE VC Not initialized. +* +* @pre vc_setting_initialize() should be successful. +* +* @see vc_setting_unset_current_language_changed_cb() +*/ +int vc_setting_set_current_language_changed_cb(vc_setting_current_language_changed_cb callback, void* user_data); + +/** +* @brief Unregisters the callback function. +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_ERROR_NONE Success. +* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter. +* @retval #VC_ERROR_INVALID_STATE VC Not initialized. +* +* @pre vc_setting_initialize() should be successful. +* +* @see vc_setting_set_current_language_changed_cb() +*/ +int vc_setting_unset_current_language_changed_cb(); + #ifdef __cplusplus } diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index d983658..c54ffaf 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -97,7 +97,7 @@ install LICENSE %{buildroot}/usr/share/license/%{name} %post /sbin/ldconfig -mkdir -p /usr/share/voice/vc +mkdir -p %{_libdir}/voice/vc %postun -p /sbin/ldconfig @@ -109,9 +109,9 @@ mkdir -p /usr/share/voice/vc %{_libdir}/libvc_widget.so %{_libdir}/libvc_manager.so %{_bindir}/vc-daemon +%{_libdir}/voice/vc/1.0/vc-config.xml /usr/share/dbus-1/services/org.tizen.voice* /etc/dbus-1/session.d/vc-server.conf -/usr/share/voice/vc/vc-config.xml /usr/share/license/%{name} %files devel diff --git a/server/vcd_config.c b/server/vcd_config.c index ee0047a..7060d3a 100644 --- a/server/vcd_config.c +++ b/server/vcd_config.c @@ -22,12 +22,12 @@ static vcd_config_lang_changed_cb g_lang_cb; -static vcd_config_foreground_changed_cb g_fore_cb; - static void* g_user_data; static vcd_state_e g_state; +static int g_foreground_pid; + void __vcd_config_lang_changed_cb(const char* before_lang, const char* current_lang) { @@ -37,13 +37,6 @@ void __vcd_config_lang_changed_cb(const char* before_lang, const char* current_l SLOG(LOG_ERROR, TAG_VCD, "Language changed callback is NULL"); } -void __vcd_config_foreground_changed_cb(int previous, int current) -{ - if (NULL != g_fore_cb) - g_fore_cb(previous, current, g_user_data); - else - SLOG(LOG_ERROR, TAG_VCD, "Foreground changed callback is NULL"); -} int vcd_config_initialize(vcd_config_lang_changed_cb lang_cb, vcd_config_foreground_changed_cb fore_cb, void* user_data) { @@ -65,22 +58,16 @@ int vcd_config_initialize(vcd_config_lang_changed_cb lang_cb, vcd_config_foregro return VCD_ERROR_OPERATION_FAILED; } - ret = vc_config_mgr_set_foreground_cb(getpid(), __vcd_config_foreground_changed_cb); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set foreground changed callback : %d", ret); - return VCD_ERROR_OPERATION_FAILED; - } - g_lang_cb = lang_cb; - g_fore_cb = fore_cb; g_user_data = user_data; + g_foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; + return 0; } int vcd_config_finalize() { - vc_config_mgr_unset_foreground_cb(getpid()); vc_config_mgr_unset_lang_cb(getpid()); vc_config_mgr_finalize(getpid()); return 0; @@ -115,5 +102,18 @@ vcd_state_e vcd_config_get_service_state() int vcd_config_get_foreground(int* pid) { - return vc_config_mgr_get_foreground(pid); + *pid = g_foreground_pid; + return 0; +} + +int vcd_config_set_foreground(int pid, bool value) +{ + if (true == value) { + g_foreground_pid = pid; + } else { + if (pid == g_foreground_pid) { + g_foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; + } + } + return 0; } diff --git a/server/vcd_config.h b/server/vcd_config.h index f922706..2cf332f 100644 --- a/server/vcd_config.h +++ b/server/vcd_config.h @@ -41,6 +41,8 @@ vcd_state_e vcd_config_get_service_state(); int vcd_config_get_foreground(int* pid); +int vcd_config_set_foreground(int pid, bool value); + #ifdef __cplusplus } diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 0b03140..f24f39f 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -26,6 +26,10 @@ 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) { @@ -34,15 +38,13 @@ static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e char target_if_name[128] = {0,}; if (VCD_CLIENT_TYPE_NORMAL == type) { - snprintf(service_name, 64, "%s", VC_CLIENT_SERVICE_NAME); + 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", VC_WIDGET_SERVICE_NAME); + 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); @@ -51,12 +53,11 @@ static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e return NULL; } - return dbus_message_new_signal(object_path, target_if_name, method); + return dbus_message_new_method_call(service_name, object_path, target_if_name, method); } int vcdc_send_hello(int pid, vcd_client_type_e type) { -#if 0 DBusMessage* msg = NULL; if (VCD_CLIENT_TYPE_NORMAL == type) { @@ -64,7 +65,7 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) } else if (VCD_CLIENT_TYPE_WIDGET == type) { msg = __get_message(pid, VCD_WIDGET_METHOD_HELLO, VCD_CLIENT_TYPE_WIDGET); } else if (VCD_CLIENT_TYPE_MANAGER == type) { - msg = __get_message(pid, VCD_WIDGET_METHOD_HELLO, VCD_CLIENT_TYPE_MANAGER); + msg = __get_message(pid, VCD_MANAGER_METHOD_HELLO, VCD_CLIENT_TYPE_MANAGER); } else { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); return -1; @@ -88,6 +89,13 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] %s", err.message); + if (NULL != err.name) { + if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Unknown service. Client is not available"); + dbus_error_free(&err); + return 0; + } + } dbus_error_free(&err); } @@ -103,12 +111,9 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) dbus_message_unref(result_msg); } else { SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] Result message is NULL. Client is not available"); - result = 0; } return result; -#endif - return 1; } int vcdc_send_show_tooltip(int pid, bool show) @@ -118,14 +123,22 @@ int vcdc_send_show_tooltip(int pid, bool show) return -1; } + char service_name[64] = {0, }; + memset(service_name, 0, 64); + snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); + + char target_if_name[128] = {0, }; + snprintf(target_if_name, sizeof(target_if_name), "%s", VC_WIDGET_SERVICE_INTERFACE); + DBusMessage* msg; SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] send widget show tooltip signal : pid(%d) show(%d)", pid, show); - msg = dbus_message_new_signal( - VC_WIDGET_SERVICE_OBJECT_PATH, - VC_WIDGET_SERVICE_INTERFACE, - VCD_WIDGET_METHOD_SHOW_TOOLTIP); + msg = dbus_message_new_method_call( + service_name, + VC_WIDGET_SERVICE_OBJECT_PATH, + target_if_name, + VCD_WIDGET_METHOD_SHOW_TOOLTIP); if (NULL == msg) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message"); @@ -141,6 +154,8 @@ int vcdc_send_show_tooltip(int pid, bool show) dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &pid); dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(temp)); + dbus_message_set_no_reply(msg, TRUE); + 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; @@ -177,8 +192,14 @@ int vcdc_send_set_volume(int manger_pid, float volume) dbus_message_unref(msg); return -1; } else { - SLOG(LOG_DEBUG, TAG_VCD, "<<<< Send set volume : pid(%d), volume(%f)", manger_pid, volume); + if (10 == g_volume_count) { + SLOG(LOG_DEBUG, TAG_VCD, "<<<< Send set volume : pid(%d), volume(%f)", manger_pid, volume); + g_volume_count = 0; + } + dbus_connection_flush(g_conn_sender); + + g_volume_count++; } dbus_message_unref(msg); @@ -217,7 +238,7 @@ int vcdc_send_result(int pid, int cmd_type) return VCD_ERROR_OUT_OF_MEMORY; } - dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); + dbus_message_set_no_reply(msg, TRUE); if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); @@ -250,6 +271,8 @@ int vcdc_send_result_to_manager(int manger_pid, int result_type) dbus_message_append_args(msg, DBUS_TYPE_INT32, &result_type, DBUS_TYPE_INVALID); + dbus_message_set_no_reply(msg, TRUE); + 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; @@ -278,6 +301,8 @@ int vcdc_send_speech_detected(int manger_pid) return VCD_ERROR_OUT_OF_MEMORY; } + dbus_message_set_no_reply(msg, TRUE); + 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; @@ -380,13 +405,17 @@ int vcdc_send_error_signal(int pid, int reason, char *err_msg) return VCD_ERROR_INVALID_PARAMETER; } + char service_name[64] = {0, }; + snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); + DBusMessage* msg; SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] send error signal : reason(%d), Error Msg(%s)", reason, err_msg); - msg = dbus_message_new_signal( - VC_CLIENT_SERVICE_OBJECT_PATH, - VC_CLIENT_SERVICE_INTERFACE, - VCD_METHOD_ERROR); + msg = dbus_message_new_method_call( + service_name, + VC_CLIENT_SERVICE_OBJECT_PATH, + VC_CLIENT_SERVICE_INTERFACE, + VCD_METHOD_ERROR); if (NULL == msg) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message"); @@ -399,6 +428,8 @@ int vcdc_send_error_signal(int pid, int reason, char *err_msg) DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); + dbus_message_set_no_reply(msg, TRUE); + 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; @@ -418,105 +449,113 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle dbus_connection_read_write_dispatch(g_conn_listener, 50); - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_conn_listener); + 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) { - return ECORE_CALLBACK_RENEW; - } + /* loop again if we haven't read a message */ + if (NULL == msg) { + 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); + /* Common event */ + if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_HELLO)) + vcd_dbus_server_hello(g_conn_listener, msg); - /* manager event */ - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_INITIALIZE)) - vcd_dbus_server_mgr_initialize(g_conn_listener, msg); + /* manager event */ + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_INITIALIZE)) + vcd_dbus_server_mgr_initialize(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_FINALIZE)) - vcd_dbus_server_mgr_finalize(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_FINALIZE)) + vcd_dbus_server_mgr_finalize(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_COMMAND)) - vcd_dbus_server_mgr_set_command(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_COMMAND)) + vcd_dbus_server_mgr_set_command(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_UNSET_COMMAND)) - vcd_dbus_server_mgr_unset_command(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_UNSET_COMMAND)) + vcd_dbus_server_mgr_unset_command(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_DEMANDABLE)) - vcd_dbus_server_mgr_set_demandable_client(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_DEMANDABLE)) + vcd_dbus_server_mgr_set_demandable_client(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_AUDIO_TYPE)) - vcd_dbus_server_mgr_set_audio_type(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_AUDIO_TYPE)) + vcd_dbus_server_mgr_set_audio_type(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_GET_AUDIO_TYPE)) - vcd_dbus_server_mgr_get_audio_type(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_GET_AUDIO_TYPE)) + vcd_dbus_server_mgr_get_audio_type(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_CLIENT_INFO)) - vcd_dbus_server_mgr_set_client_info(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SET_CLIENT_INFO)) + vcd_dbus_server_mgr_set_client_info(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_START)) - vcd_dbus_server_mgr_start(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_START)) + vcd_dbus_server_mgr_start(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_STOP)) - vcd_dbus_server_mgr_stop(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_STOP)) + vcd_dbus_server_mgr_stop(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_CANCEL)) - vcd_dbus_server_mgr_cancel(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_CANCEL)) + vcd_dbus_server_mgr_cancel(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_RESULT_SELECTION)) - vcd_dbus_server_mgr_result_selection(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_RESULT_SELECTION)) + vcd_dbus_server_mgr_result_selection(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); + /* 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); + 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); + 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_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_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); #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_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_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); + 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 - /* widget event */ - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_INITIALIZE)) - vcd_dbus_server_widget_initialize(g_conn_listener, msg); + /* widget event */ + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_INITIALIZE)) + vcd_dbus_server_widget_initialize(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_FINALIZE)) - vcd_dbus_server_widget_finalize(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_FINALIZE)) + vcd_dbus_server_widget_finalize(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_START_RECORDING)) - vcd_dbus_server_widget_start_recording(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_START_RECORDING)) + vcd_dbus_server_widget_start_recording(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_START)) - vcd_dbus_server_widget_start(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_START)) + vcd_dbus_server_widget_start(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_STOP)) - vcd_dbus_server_widget_stop(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_STOP)) + vcd_dbus_server_widget_stop(g_conn_listener, msg); - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_CANCEL)) - vcd_dbus_server_widget_cancel(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_CANCEL)) + vcd_dbus_server_widget_cancel(g_conn_listener, msg); - else - return ECORE_CALLBACK_RENEW; + else { + SLOG(LOG_DEBUG, TAG_VCD, "Message is NOT valid"); + dbus_message_unref(msg); + break; + } - /* free the message */ - dbus_message_unref(msg); + /* free the message */ + dbus_message_unref(msg); + } return ECORE_CALLBACK_RENEW; } @@ -613,6 +652,9 @@ int vcd_dbus_close_connection() dbus_error_free(&err); } + dbus_connection_close(g_conn_listener); + dbus_connection_close(g_conn_sender); + g_conn_listener = NULL; g_conn_sender = NULL; diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c index e2e826d..3f2741b 100644 --- a/server/vcd_dbus_server.c +++ b/server/vcd_dbus_server.c @@ -89,6 +89,7 @@ int vcd_dbus_server_mgr_initialize(DBusConnection* conn, DBusMessage* msg) int pid; int service_state; + int foreground; int ret = VCD_ERROR_OPERATION_FAILED; dbus_message_get_args(msg, &err, @@ -102,9 +103,11 @@ int vcd_dbus_server_mgr_initialize(DBusConnection* conn, DBusMessage* msg) dbus_error_free(&err); ret = VCD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr initialize : pid(%d)", pid); ret = vcd_server_mgr_initialize(pid); service_state = vcd_server_get_service_state(); + foreground = vcd_server_get_foreground(); + + SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr initialize : pid(%d) service state(%d) foreground(%d)", pid, service_state, foreground); } DBusMessage* reply; @@ -114,6 +117,7 @@ int vcd_dbus_server_mgr_initialize(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &service_state, + DBUS_TYPE_INT32, &foreground, DBUS_TYPE_INVALID); if (0 == ret) { @@ -984,6 +988,34 @@ int vcd_dbus_server_unset_command(DBusConnection* conn, DBusMessage* msg) 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_DEBUG, 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, "<<<<<"); + SLOG(LOG_DEBUG, TAG_VCD, " "); + + return 0; +} + #if 0 int vcd_dbus_server_start_request(DBusConnection* conn, DBusMessage* msg) { diff --git a/server/vcd_dbus_server.h b/server/vcd_dbus_server.h index 2af9dac..4011693 100644 --- a/server/vcd_dbus_server.h +++ b/server/vcd_dbus_server.h @@ -71,6 +71,8 @@ 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); + #if 0 int vcd_dbus_server_start_request(DBusConnection* conn, DBusMessage* msg); diff --git a/server/vcd_main.c b/server/vcd_main.c index 5eb0b5a..906f58a 100644 --- a/server/vcd_main.c +++ b/server/vcd_main.c @@ -44,7 +44,7 @@ int main(int argc, char** argv) return EXIT_FAILURE; } - g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, vcd_cleanup_client, NULL); + g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, vcd_cleanup_client_all, NULL); if (NULL == g_check_client_timer) { SLOG(LOG_WARN, TAG_VCD, "[Main Warning] Fail to create timer of client check"); } diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index c2d1607..e2692a9 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -16,7 +16,6 @@ #include -#include #include #include diff --git a/server/vcd_server.c b/server/vcd_server.c index a4c2bb7..cfb8289 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -34,6 +34,8 @@ */ static bool g_is_engine; +static GList *g_proc_list = NULL; + /* * VC Server Internal Functions */ @@ -534,6 +536,15 @@ int vcd_initialize() void vcd_finalize() { + GList *iter = NULL; + if (0 < g_list_length(g_proc_list)) { + iter = g_list_first(g_proc_list); + while (NULL != iter) { + g_proc_list = g_list_remove_link(g_proc_list, iter); + iter = g_list_first(g_proc_list); + } + } + vcd_state_e state = vcd_config_get_service_state(); if (VCD_STATE_READY != state) { if (VCD_STATE_RECORDING == state) { @@ -568,18 +579,136 @@ static Eina_Bool __finalize_quit_ecore_loop(void *data) return EINA_FALSE; } -Eina_Bool vcd_cleanup_client(void *data) +static void __read_proc() +{ + DIR *dp = NULL; + struct dirent entry; + struct dirent *dirp = NULL; + int ret = -1; + int tmp; + + GList *iter = NULL; + if (0 < g_list_length(g_proc_list)) { + iter = g_list_first(g_proc_list); + while (NULL != iter) { + g_proc_list = g_list_remove_link(g_proc_list, iter); + iter = g_list_first(g_proc_list); + } + } + + dp = opendir("/proc"); + if (NULL == dp) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open proc"); + } else { + do { + ret = readdir_r(dp, &entry, &dirp); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to readdir"); + break; + } + + if (NULL != dirp) { + tmp = atoi(dirp->d_name); + if (0 >= tmp) continue; + g_proc_list = g_list_append(g_proc_list, GINT_TO_POINTER(tmp)); + } + } while (NULL != dirp); + closedir(dp); + } + return; +} + +static void __vcd_cleanup_client(vcd_client_type_e type) { -#if 0 int* client_list = NULL; int client_count = 0; - int result; int i = 0; + int j = 0; + bool exist = false; + int mgr_pid = -1; + int ret = -1; + + if (VCD_CLIENT_TYPE_NORMAL == type) { + ret = vcd_client_get_list(&client_list, &client_count); + } + else if (VCD_CLIENT_TYPE_WIDGET == type) { + ret = vcd_client_widget_get_list(&client_list, &client_count); + } + else if (VCD_CLIENT_TYPE_MANAGER == type) { + mgr_pid = vcd_client_manager_get_pid(); + client_list = &mgr_pid; + client_count = 1; + } + + if (0 == ret || mgr_pid > 0) { + SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up %s client ", type ? (type == 1) ? "Widget" : "Manager" : "Normal"); + if (NULL != client_list && client_count > 0) { + for (i = 0; i < client_count; i++) { + exist = false; + GList *iter = NULL; + for (j = 0; j < g_list_length(g_proc_list); j++) { + iter = g_list_nth(g_proc_list, j); + if (NULL != iter) { + if (client_list[i] == GPOINTER_TO_INT(iter->data)) { + SLOG(LOG_DEBUG, TAG_VCD, "%s pid(%d) is running", type ? (type == 1) ? "Widget" : "Manager" : "Normal", client_list[i]); + exist = true; + break; + } + } + } + + if (false == exist) { + SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == 1) ? "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) + vcd_server_widget_finalize(client_list[i]); + else + vcd_server_mgr_finalize(mgr_pid); + } + } + } + SLOG(LOG_DEBUG, TAG_VCD, "====="); + SLOG(LOG_DEBUG, TAG_VCD, " "); + } + if (NULL != client_list && -1 == mgr_pid) { + free(client_list); + client_list = NULL; + } + return; +} + +Eina_Bool vcd_cleanup_client_all(void *data) +{ + __read_proc(); + + __vcd_cleanup_client(VCD_CLIENT_TYPE_NORMAL); + __vcd_cleanup_client(VCD_CLIENT_TYPE_WIDGET); + __vcd_cleanup_client(VCD_CLIENT_TYPE_MANAGER); +#if 0 if (0 == vcd_client_get_list(&client_list, &client_count)) { SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up client "); if (NULL != client_list && client_count > 0) { for (i = 0; i < client_count; i++) { + exist = false; + GList *iter = NULL; + for (j = 0; j < g_list_length(g_proc_list); j++) { + iter = g_list_nth(g_proc_list, j); + if (NULL != iter) { + if (client_list[i] == GPOINTER_TO_INT(iter->data)) { + SLOG(LOG_DEBUG, TAG_VCD, "pid(%d) is running", client_list[i]); + exist = true; + break; + } + } + } + + if (false == exist) { + SLOG(LOG_ERROR, TAG_VCD, "pid(%d) should be removed", client_list[i]); + vcd_server_finalize(client_list[i]); + } +#if 0 result = vcdc_send_hello(client_list[i], VCD_CLIENT_TYPE_NORMAL); if (0 == result) { @@ -588,6 +717,7 @@ Eina_Bool vcd_cleanup_client(void *data) } else if (-1 == result) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Hello result has error"); } +#endif } } SLOG(LOG_DEBUG, TAG_VCD, "====="); @@ -597,14 +727,30 @@ Eina_Bool vcd_cleanup_client(void *data) free(client_list); client_list = NULL; } -#endif -#if 0 /* If app is in background state, app cannot response message. */ if (0 == vcd_client_widget_get_list(&client_list, &client_count)) { SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up widget"); if (NULL != client_list && client_count > 0) { for (i = 0; i < client_count; i++) { + exist = false; + GList *iter = NULL; + for (j = 0; j < g_list_length(g_proc_list); j++) { + iter = g_list_nth(g_proc_list, j); + if (NULL != iter) { + if (client_list[i] == GPOINTER_TO_INT(iter->data)) { + SLOG(LOG_DEBUG, TAG_VCD, "widget pid(%d) is running", client_list[i]); + exist = true; + break; + } + } + } + + if (false == exist) { + SLOG(LOG_ERROR, TAG_VCD, "widget pid(%d) should be removed", client_list[i]); + vcd_server_widget_finalize(client_list[i]); + } +#if 0 result = vcdc_send_hello(client_list[i], VCD_CLIENT_TYPE_WIDGET); if (0 == result) { @@ -613,6 +759,7 @@ Eina_Bool vcd_cleanup_client(void *data) } else if (-1 == result) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Hello result has error"); } +#endif } } SLOG(LOG_DEBUG, TAG_VCD, "====="); @@ -623,10 +770,29 @@ Eina_Bool vcd_cleanup_client(void *data) free(client_list); client_list = NULL; } -#endif /* manager */ + exist = false; + GList *iter = NULL; + int mgr_pid = vcd_client_manager_get_pid(); + if (0 < mgr_pid) { + for (j = 0; j < g_list_length(g_proc_list); j++) { + iter = g_list_nth(g_proc_list, j); + if (NULL != iter) { + if (mgr_pid == GPOINTER_TO_INT(iter->data)) { + SLOG(LOG_DEBUG, TAG_VCD, "manager pid(%d) is running", mgr_pid); + exist = true; + break; + } + } + } + if (false == exist) { + SLOG(LOG_ERROR, TAG_VCD, "manager pid (%d) should be removed", mgr_pid); + vcd_server_mgr_finalize(mgr_pid); + } + } +#endif return EINA_TRUE; } @@ -635,6 +801,14 @@ int vcd_server_get_service_state() return vcd_config_get_service_state(); } +int vcd_server_get_foreground() +{ + int pid; + vcd_config_get_foreground(&pid); + return pid; +} + + /* * API for manager */ @@ -675,6 +849,9 @@ int vcd_server_mgr_finalize(int pid) return VCD_ERROR_INVALID_PARAMETER; } + /* Cancel recognition */ + vcd_server_mgr_cancel(); + /* Remove manager information */ if (0 != vcd_client_manager_unset()) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to delete client"); @@ -819,8 +996,13 @@ static int __start_internal_recognition() SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Set command"); + bool stop_by_silence = true; + if (VCD_RECOGNITION_MODE_MANUAL == vcd_client_get_recognition_mode()) { + stop_by_silence = false; + } + /* 4. start recognition */ - ret = vcd_engine_recognize_start(true); + ret = vcd_engine_recognize_start(stop_by_silence); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recognition : result(%d)", ret); return VCD_ERROR_OPERATION_FAILED; @@ -839,7 +1021,7 @@ static int __start_internal_recognition() vcd_config_set_service_state(VCD_STATE_RECORDING); vcdc_send_service_state(VCD_STATE_RECORDING); - SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start recognition"); + SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence); return 0; } @@ -1066,6 +1248,22 @@ int vcd_server_unset_command(int pid, vc_cmd_type_e cmd_type) return 0; } +int vcd_server_set_foreground(int pid, bool value) +{ + /* check if pid is valid */ + if (false == vcd_client_is_available(pid) && false == vcd_client_widget_is_available(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] pid is NOT valid "); + return VCD_ERROR_INVALID_PARAMETER; + } + + if (0 != vcd_config_set_foreground(pid, value)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set foreground : pid(%d), value(%d)", pid, value); + return VCD_ERROR_OPERATION_FAILED; + } + + return 0; +} + #if 0 int vcd_server_set_exclusive_command(int pid, bool value) { @@ -1257,7 +1455,7 @@ int vcd_server_widget_start_recording(int pid, bool widget_command) SLOG(LOG_DEBUG, TAG_VCD, "[Server] widget command is available"); } else { vcd_client_widget_unset_command(pid); - SLOG(LOG_DEBUG, TAG_VCD, "[Server] widget command is NOT available"); + SLOG(LOG_WARN, TAG_VCD, "[Server] widget command is NOT available"); } int ret = __start_internal_recognition(); diff --git a/server/vcd_server.h b/server/vcd_server.h index 3fa4fc8..fc7217d 100644 --- a/server/vcd_server.h +++ b/server/vcd_server.h @@ -32,10 +32,12 @@ int vcd_initialize(); void vcd_finalize(); -Eina_Bool vcd_cleanup_client(void *data); +Eina_Bool vcd_cleanup_client_all(void *data); int vcd_server_get_service_state(); +int vcd_server_get_foreground(); + /* * For manager @@ -75,9 +77,11 @@ int vcd_server_set_command(int pid, vc_cmd_type_e cmd_type); int vcd_server_unset_command(int pid, vc_cmd_type_e cmd_type); -int vcd_server_set_exclusive_command(int pid, bool value); +int vcd_server_set_foreground(int pid, bool value); #if 0 +int vcd_server_set_exclusive_command(int pid, bool value); + int vcd_server_request_start(int pid, bool stop_by_silence); int vcd_server_request_stop(int pid); -- 2.7.4 From 5ea4cb4f5953f1d15a2c55e2f46a67c17349f034 Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Thu, 7 Apr 2016 16:49:19 +0900 Subject: [PATCH 11/16] update directory path for migration Change-Id: I40dc8958b5a80cb3bd1fceee5bb26a364670237c Signed-off-by: ky85.kim --- CMakeLists.txt | 4 ++-- common/vc_defs.h | 19 +++++++++++-------- packaging/voice-control.spec | 13 +++++++------ server/vcd_engine_agent.c | 7 +++---- server/vcd_main.h | 9 --------- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1158e48..acadb9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,8 @@ ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(server) ## config ## -INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION ${LIBDIR}/voice/vc/1.0) +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 /usr/share/dbus-1/services) +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) diff --git a/common/vc_defs.h b/common/vc_defs.h index 53e1ba6..268a2d8 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -141,21 +141,21 @@ extern "C" { * Defines for configuration *******************************************************************************************/ -#define VC_DAEMON_PATH "/usr/bin/vc-daemon" +#define VC_DAEMON_PATH tzplatform_mkpath(TZ_SYS_BIN, "vc-daemon") -#define VC_CONFIG_DEFAULT VOICE_LIBDIR"/voice/vc/1.0/vc-config.xml" +#define VC_CONFIG_DEFAULT tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/vc-config.xml") -#define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice") -#define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc-config.xml") +#define VC_DEFAULT_BASE tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/1.0") -#define VC_DEFAULT_ENGINE_INFO VOICE_LIBDIR"/voice/vc/1.0/engine-info" +#define VC_DEFAULT_ENGINE tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/1.0/engine") -#define VC_NO_FOREGROUND_PID 0 +#define VC_DEFAULT_ENGINE_SETTING tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/1.0/engine-setting") -#define VC_BASE_LANGUAGE "en_US" +#define VC_DEFAULT_ENGINE_INFO tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/1.0/engine-info") -#define VC_RETRY_COUNT 5 +#define VC_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice") +#define VC_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc-config.xml") #define VC_RUNTIME_INFO_ROOT tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc") @@ -169,6 +169,9 @@ extern "C" { #define VC_RUNTIME_INFO_CLIENT tzplatform_mkpath(TZ_USER_HOME, "share/.voice/vc/vc-client-info.xml") +#define VC_NO_FOREGROUND_PID 0 +#define VC_BASE_LANGUAGE "en_US" +#define VC_RETRY_COUNT 5 #define VC_RUNTIME_INFO_NO_FOREGROUND -1 #define VC_FEATURE_PATH "tizen.org/feature/speech.control" diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index c54ffaf..cf2580a 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -84,13 +84,14 @@ export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE" export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE" export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE" %endif -cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \ + -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE make %{?jobs:-j%jobs} %install rm -rf %{buildroot} -mkdir -p %{buildroot}/usr/share/license -install LICENSE %{buildroot}/usr/share/license/%{name} +mkdir -p %{buildroot}%{TZ_SYS_RO_SHARE}/license +install LICENSE %{buildroot}%{TZ_SYS_RO_SHARE}/license/%{name} %make_install @@ -109,10 +110,10 @@ mkdir -p %{_libdir}/voice/vc %{_libdir}/libvc_widget.so %{_libdir}/libvc_manager.so %{_bindir}/vc-daemon -%{_libdir}/voice/vc/1.0/vc-config.xml -/usr/share/dbus-1/services/org.tizen.voice* +%{TZ_SYS_RO_SHARE}/voice/vc/1.0/vc-config.xml +%{TZ_SYS_RO_SHARE}/dbus-1/services/org.tizen.voice* +%{TZ_SYS_RO_SHARE}/license/%{name} /etc/dbus-1/session.d/vc-server.conf -/usr/share/license/%{name} %files devel %manifest %{name}-devel.manifest diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 3b99ae5..cdba7fe 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -293,7 +293,6 @@ int __internal_get_engine_info(const char* filepath, vcengine_info_s** info) void* handle; handle = dlopen(filepath, RTLD_LAZY); - if (!handle) { SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Invalid engine : %s", filepath); return -1; @@ -389,7 +388,7 @@ int __internal_update_engine_list() struct dirent entry; struct dirent *dirp = NULL; - dp = opendir(ENGINE_DIRECTORY_DEFAULT); + dp = opendir(VC_DEFAULT_ENGINE); if (NULL != dp) { do { ret = readdir_r(dp, &entry, &dirp); @@ -403,11 +402,11 @@ int __internal_update_engine_list() char* filepath = NULL; int filesize = 0; - filesize = strlen(ENGINE_DIRECTORY_DEFAULT) + strlen(dirp->d_name) + 5; + filesize = strlen(VC_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5; filepath = (char*)calloc(filesize, sizeof(char)); if (NULL != filepath) { - snprintf(filepath, filesize, "%s/%s", ENGINE_DIRECTORY_DEFAULT, dirp->d_name); + snprintf(filepath, filesize, "%s/%s", VC_DEFAULT_ENGINE, dirp->d_name); } else { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Memory not enough!!"); continue; diff --git a/server/vcd_main.h b/server/vcd_main.h index 51af598..b56650c 100644 --- a/server/vcd_main.h +++ b/server/vcd_main.h @@ -41,15 +41,6 @@ extern "C" { #define TAG_VCD "vcd" -#define BASE_DIRECTORY_DEFAULT "/usr/lib/voice/vc/1.0" -#define ENGINE_DIRECTORY_DEFAULT "/usr/lib/voice/vc/1.0/engine" -#define ENGINE_DIRECTORY_DEFAULT_SETTING "/usr/lib/voice/vc/setting" - -#define CONFIG_DIRECTORY "/opt/home/app/.voice" - -#define ENGINE_DIRECTORY_DOWNLOAD "/opt/usr/voice/vc/engine" -#define ENGINE_DIRECTORY_DOWNLOAD_SETTING "/opt/usr/voice/vc/setting" - /* for debug message */ /* #define RECORDER_DEBUG */ #define CLIENT_DATA_DEBUG -- 2.7.4 From 0349c3b69b9d72e451f997a6bbd4b9b836f96285 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 18 Apr 2016 09:46:38 +0900 Subject: [PATCH 12/16] check and revise by coding rule Change-Id: I5017fbb7b886a290b93ab8c30f7c146300edb9a9 Signed-off-by: sooyeon.kim --- include/voice_control_plugin_engine.h | 30 +++++++++++++++--------------- server/vcd_server.c | 6 ++---- 2 files changed, 17 insertions(+), 19 deletions(-) mode change 100644 => 100755 include/voice_control_plugin_engine.h mode change 100644 => 100755 server/vcd_server.c diff --git a/include/voice_control_plugin_engine.h b/include/voice_control_plugin_engine.h old mode 100644 new mode 100755 index 878c596..ff091d3 --- a/include/voice_control_plugin_engine.h +++ b/include/voice_control_plugin_engine.h @@ -148,7 +148,7 @@ typedef bool (*vcpe_supported_language_cb)(const char* language, void* user_data * * @see vcpe_deinitialize() */ -typedef int (* vcpe_initialize)(void); +typedef int (*vcpe_initialize)(void); /** * @brief Deinitializes the engine @@ -159,7 +159,7 @@ typedef int (* vcpe_initialize)(void); * * @see vcpe_initialize() */ -typedef void (* vcpe_deinitialize)(void); +typedef void (*vcpe_deinitialize)(void); /** * @brief Registers a callback function for getting recognition result. @@ -173,7 +173,7 @@ typedef void (* vcpe_deinitialize)(void); * * @see vcpe_result_cb() */ -typedef int (* vcpe_set_result_cb)(vcpe_result_cb callback, void* user_data); +typedef int (*vcpe_set_result_cb)(vcpe_result_cb callback, void* user_data); /** * @brief Gets recording format of the engine. @@ -187,7 +187,7 @@ typedef int (* vcpe_set_result_cb)(vcpe_result_cb callback, void* user_data); * @retval #VCP_ERROR_NONE Successful * @retval #VCP_ERROR_INVALID_PARAMETER Not initialized */ -typedef int (* vcpe_get_recording_format)(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels); +typedef int (*vcpe_get_recording_format)(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels); /** * @brief Retrieves all supported languages of the engine. @@ -204,7 +204,7 @@ typedef int (* vcpe_get_recording_format)(const char* audio_id, vcp_audio_type_e * * @see vcpe_supported_language_cb() */ -typedef int (* vcpe_foreach_supported_languages)(vcpe_supported_language_cb callback, void* user_data); +typedef int (*vcpe_foreach_supported_languages)(vcpe_supported_language_cb callback, void* user_data); /** * @brief Checks whether a language is supported or not. @@ -213,7 +213,7 @@ typedef int (* vcpe_foreach_supported_languages)(vcpe_supported_language_cb call * * @return @c true = supported, \n @c false = not supported. */ -typedef bool (* vcpe_is_language_supported)(const char* language); +typedef bool (*vcpe_is_language_supported)(const char* language); /** * @brief Sets language. @@ -247,7 +247,7 @@ typedef int (*vcpe_set_language)(const char* language); * @see vcpd_foreach_command() * @see vcpe_unset_commands() */ -typedef int (* vcpe_set_commands)(vcp_cmd_h vcp_command); +typedef int (*vcpe_set_commands)(vcp_cmd_h vcp_command); /** * @brief Unset command list for reset. @@ -260,7 +260,7 @@ typedef int (* vcpe_set_commands)(vcp_cmd_h vcp_command); * * @see vcpe_set_commands() */ -typedef int (* vcpe_unset_commands)(); +typedef int (*vcpe_unset_commands)(); /** * @brief Start recognition. @@ -279,7 +279,7 @@ typedef int (* vcpe_unset_commands)(); * @see vcpe_stop() * @see vcpe_cancel() */ -typedef int (* vcpe_start)(bool stop_by_silence); +typedef int (*vcpe_start)(bool stop_by_silence); /** * @brief Sets recording data for speech recognition from recorder. @@ -320,7 +320,7 @@ typedef int(*vcpe_set_recording_data)(const void* data, unsigned int length, vcp * @see vcpe_result_cb() * @see vcpe_cancel() */ -typedef int (* vcpe_stop)(void); +typedef int (*vcpe_stop)(void); /** * @brief Cancels the recognition process. @@ -334,7 +334,7 @@ typedef int (* vcpe_stop)(void); * @see vcpe_start() * @see vcpe_stop() */ -typedef int (* vcpe_cancel)(void); +typedef int (*vcpe_cancel)(void); /** @@ -356,7 +356,7 @@ typedef int (* vcpe_cancel)(void); * * @see vcpd_foreach_command() */ -typedef bool (* vcpd_foreach_command_cb)(int id, int type, const char* command, const char* param, int domain, void* user_data); +typedef bool (*vcpd_foreach_command_cb)(int id, int type, const char* command, const char* param, int domain, void* user_data); /** * @brief Retrieves all commands using callback function. @@ -376,7 +376,7 @@ typedef bool (* vcpd_foreach_command_cb)(int id, int type, const char* command, * @see vcpd_foreach_command_cb() * @see vcpe_set_commands() */ -typedef int (* vcpd_foreach_command)(vcp_cmd_h vcp_command, vcpd_foreach_command_cb callback, void* user_data); +typedef int (*vcpd_foreach_command)(vcp_cmd_h vcp_command, vcpd_foreach_command_cb callback, void* user_data); /** * @brief Gets command length. @@ -387,7 +387,7 @@ typedef int (* vcpd_foreach_command)(vcp_cmd_h vcp_command, vcpd_foreach_command * * @see vcpe_set_commands() */ -typedef int (* vcpd_get_command_count)(vcp_cmd_h vcp_command); +typedef int (*vcpd_get_command_count)(vcp_cmd_h vcp_command); /** * @brief Gets current audio type. @@ -399,7 +399,7 @@ typedef int (* vcpd_get_command_count)(vcp_cmd_h vcp_command); * @return the value greater than 0 on success, otherwise a negative error value * */ -typedef int (* vcpd_get_audio_type)(char** audio_type); +typedef int (*vcpd_get_audio_type)(char** audio_type); /** * @brief A structure of the engine functions. diff --git a/server/vcd_server.c b/server/vcd_server.c old mode 100644 new mode 100755 index cfb8289..345d9f3 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -630,11 +630,9 @@ static void __vcd_cleanup_client(vcd_client_type_e type) if (VCD_CLIENT_TYPE_NORMAL == type) { ret = vcd_client_get_list(&client_list, &client_count); - } - else if (VCD_CLIENT_TYPE_WIDGET == type) { + } else if (VCD_CLIENT_TYPE_WIDGET == type) { ret = vcd_client_widget_get_list(&client_list, &client_count); - } - else if (VCD_CLIENT_TYPE_MANAGER == type) { + } else if (VCD_CLIENT_TYPE_MANAGER == type) { mgr_pid = vcd_client_manager_get_pid(); client_list = &mgr_pid; client_count = 1; -- 2.7.4 From 37087f876003c25f62339441c1e5d55d1d6525de Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Tue, 19 Apr 2016 12:01:18 +0900 Subject: [PATCH 13/16] Fix directory path Change-Id: I48dde6ac870270cbc0d6695ae182eaa232f86aaa --- common/vc_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/vc_defs.h b/common/vc_defs.h index 268a2d8..3f09203 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -143,7 +143,7 @@ extern "C" { #define VC_DAEMON_PATH tzplatform_mkpath(TZ_SYS_BIN, "vc-daemon") -#define VC_CONFIG_DEFAULT tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/vc-config.xml") +#define VC_CONFIG_DEFAULT tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/1.0/vc-config.xml") #define VC_DEFAULT_BASE tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc/1.0") -- 2.7.4 From d40032323b5f09a198d88305d27601acbb3d0739 Mon Sep 17 00:00:00 2001 From: "ky85.kim" Date: Tue, 19 Apr 2016 20:07:36 +0900 Subject: [PATCH 14/16] Fix directory bug Change-Id: I11d3505d7746a29d6363791551c21e09e8d11531 --- common/vc_config_mgr.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index c86ec92..71afe04 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -534,6 +534,23 @@ int vc_config_mgr_initialize(int uid) g_engine_list = NULL; + if (0 != access(VC_CONFIG_BASE, F_OK)) { + if (0 != mkdir(VC_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to make directory : %s", VC_CONFIG_BASE); + return -1; + } else { + SLOG(LOG_DEBUG, vc_config_tag(), "Success to make directory : %s", VC_CONFIG_BASE); + } + } + if (0 != access(VC_RUNTIME_INFO_ROOT, F_OK)) { + if (0 != mkdir(VC_RUNTIME_INFO_ROOT, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to make directory : %s", VC_RUNTIME_INFO_ROOT); + return -1; + } else { + SLOG(LOG_DEBUG, vc_config_tag(), "Success to make directory : %s", VC_RUNTIME_INFO_ROOT); + } + } + dp = opendir(VC_DEFAULT_ENGINE_INFO); if (NULL != dp) { do { @@ -1292,4 +1309,4 @@ int __vc_config_mgr_print_client_info() SLOG(LOG_DEBUG, vc_config_tag(), "--------------------------------------------"); return 0; -} \ No newline at end of file +} -- 2.7.4 From 6d253da1e3d6de6b97d7a4521b7dd9c1ca3ff5b9 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 26 Apr 2016 14:02:38 +0900 Subject: [PATCH 15/16] check and revise by coding rule Change-Id: Ia258492f0fd553f3ce0dd7d0b2705e16cd8fca11 Signed-off-by: sooyeon.kim --- client/vc.c | 40 ++++++++++++++++++++-------------------- client/vc_mgr.c | 40 ++++++++++++++++++++-------------------- client/vc_widget.c | 36 ++++++++++++++++++------------------ 3 files changed, 58 insertions(+), 58 deletions(-) mode change 100644 => 100755 client/vc.c mode change 100644 => 100755 client/vc_mgr.c mode change 100644 => 100755 client/vc_widget.c diff --git a/client/vc.c b/client/vc.c old mode 100644 new mode 100755 index 2379dfc..e3161b6 --- a/client/vc.c +++ b/client/vc.c @@ -77,17 +77,17 @@ static int __vc_get_feature_enabled() static const char* __vc_get_error_code(vc_error_e err) { switch (err) { - case VC_ERROR_NONE: return "VC_ERROR_NONE"; break; - case VC_ERROR_OUT_OF_MEMORY: return "VC_ERROR_OUT_OF_MEMORY"; break; - case VC_ERROR_IO_ERROR: return "VC_ERROR_IO_ERROR"; break; - case VC_ERROR_INVALID_PARAMETER: return "VC_ERROR_INVALID_PARAMETER"; break; - case VC_ERROR_TIMED_OUT: return "VC_ERROR_TIMED_OUT"; break; - case VC_ERROR_RECORDER_BUSY: return "VC_ERROR_RECORDER_BUSY"; break; - case VC_ERROR_INVALID_STATE: return "VC_ERROR_INVALID_STATE"; break; - case VC_ERROR_INVALID_LANGUAGE: return "VC_ERROR_INVALID_LANGUAGE"; break; - case VC_ERROR_ENGINE_NOT_FOUND: return "VC_ERROR_ENGINE_NOT_FOUND"; break; - case VC_ERROR_OPERATION_FAILED: return "VC_ERROR_OPERATION_FAILED"; break; - default: return "Invalid error code"; break; + case VC_ERROR_NONE: return "VC_ERROR_NONE"; break; + case VC_ERROR_OUT_OF_MEMORY: return "VC_ERROR_OUT_OF_MEMORY"; break; + case VC_ERROR_IO_ERROR: return "VC_ERROR_IO_ERROR"; break; + case VC_ERROR_INVALID_PARAMETER: return "VC_ERROR_INVALID_PARAMETER"; break; + case VC_ERROR_TIMED_OUT: return "VC_ERROR_TIMED_OUT"; break; + case VC_ERROR_RECORDER_BUSY: return "VC_ERROR_RECORDER_BUSY"; break; + case VC_ERROR_INVALID_STATE: return "VC_ERROR_INVALID_STATE"; break; + case VC_ERROR_INVALID_LANGUAGE: return "VC_ERROR_INVALID_LANGUAGE"; break; + case VC_ERROR_ENGINE_NOT_FOUND: return "VC_ERROR_ENGINE_NOT_FOUND"; break; + case VC_ERROR_OPERATION_FAILED: return "VC_ERROR_OPERATION_FAILED"; break; + default: return "Invalid error code"; break; } return NULL; } @@ -648,10 +648,10 @@ int vc_get_state(vc_state_e* state) *state = temp; switch (*state) { - case VC_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'None'"); break; - case VC_STATE_INITIALIZED: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'Created'"); break; - case VC_STATE_READY: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'Ready'"); break; - default: SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state"); break; + case VC_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'None'"); break; + case VC_STATE_INITIALIZED: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'Created'"); break; + case VC_STATE_READY: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'Ready'"); break; + default: SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state"); break; } SLOG(LOG_DEBUG, TAG_VCC, "====="); @@ -698,11 +698,11 @@ int vc_get_service_state(vc_service_state_e* state) *state = service_state; switch (*state) { - case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'None'"); break; - case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Ready'"); break; - case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Recording'"); break; - case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Processing'"); break; - default: SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state"); break; + case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'None'"); break; + case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Ready'"); break; + case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Recording'"); break; + case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Processing'"); break; + default: SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state"); break; } SLOG(LOG_DEBUG, TAG_VCC, "====="); diff --git a/client/vc_mgr.c b/client/vc_mgr.c old mode 100644 new mode 100755 index cdeeee5..df07965 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -46,17 +46,17 @@ static Eina_Bool __vc_mgr_notify_result(void *data); static const char* __vc_mgr_get_error_code(vc_error_e err) { switch (err) { - case VC_ERROR_NONE: return "VC_ERROR_NONE"; break; - case VC_ERROR_OUT_OF_MEMORY: return "VC_ERROR_OUT_OF_MEMORY"; break; - case VC_ERROR_IO_ERROR: return "VC_ERROR_IO_ERROR"; break; - case VC_ERROR_INVALID_PARAMETER: return "VC_ERROR_INVALID_PARAMETER"; break; - case VC_ERROR_TIMED_OUT: return "VC_ERROR_TIMED_OUT"; break; - case VC_ERROR_RECORDER_BUSY: return "VC_ERROR_RECORDER_BUSY"; break; - case VC_ERROR_INVALID_STATE: return "VC_ERROR_INVALID_STATE"; break; - case VC_ERROR_INVALID_LANGUAGE: return "VC_ERROR_INVALID_LANGUAGE"; break; - case VC_ERROR_ENGINE_NOT_FOUND: return "VC_ERROR_ENGINE_NOT_FOUND"; break; - case VC_ERROR_OPERATION_FAILED: return "VC_ERROR_OPERATION_FAILED"; break; - default: return "Invalid error code"; break; + case VC_ERROR_NONE: return "VC_ERROR_NONE"; break; + case VC_ERROR_OUT_OF_MEMORY: return "VC_ERROR_OUT_OF_MEMORY"; break; + case VC_ERROR_IO_ERROR: return "VC_ERROR_IO_ERROR"; break; + case VC_ERROR_INVALID_PARAMETER: return "VC_ERROR_INVALID_PARAMETER"; break; + case VC_ERROR_TIMED_OUT: return "VC_ERROR_TIMED_OUT"; break; + case VC_ERROR_RECORDER_BUSY: return "VC_ERROR_RECORDER_BUSY"; break; + case VC_ERROR_INVALID_STATE: return "VC_ERROR_INVALID_STATE"; break; + case VC_ERROR_INVALID_LANGUAGE: return "VC_ERROR_INVALID_LANGUAGE"; break; + case VC_ERROR_ENGINE_NOT_FOUND: return "VC_ERROR_ENGINE_NOT_FOUND"; break; + case VC_ERROR_OPERATION_FAILED: return "VC_ERROR_OPERATION_FAILED"; break; + default: return "Invalid error code"; break; } return NULL; } @@ -392,10 +392,10 @@ int vc_mgr_get_state(vc_state_e* state) *state = temp; switch (*state) { - case VC_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCM, "Current state is 'None'"); break; - case VC_STATE_INITIALIZED: SLOG(LOG_DEBUG, TAG_VCM, "Current state is 'Created'"); break; - case VC_STATE_READY: SLOG(LOG_DEBUG, TAG_VCM, "Current state is 'Ready'"); break; - default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); break; + case VC_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCM, "Current state is 'None'"); break; + case VC_STATE_INITIALIZED: SLOG(LOG_DEBUG, TAG_VCM, "Current state is 'Created'"); break; + case VC_STATE_READY: SLOG(LOG_DEBUG, TAG_VCM, "Current state is 'Ready'"); break; + default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); break; } SLOG(LOG_DEBUG, TAG_VCM, "====="); @@ -435,11 +435,11 @@ int vc_mgr_get_service_state(vc_service_state_e* state) *state = service_state; switch (*state) { - case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'None'"); break; - case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Ready'"); break; - case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Recording'"); break; - case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Processing'"); break; - default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); break; + case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'None'"); break; + case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Ready'"); break; + case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Recording'"); break; + case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Processing'"); break; + default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); break; } SLOG(LOG_DEBUG, TAG_VCM, "====="); diff --git a/client/vc_widget.c b/client/vc_widget.c old mode 100644 new mode 100755 index 98ecd1e..7002bda --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -46,15 +46,15 @@ const char* vc_tag() static const char* __vc_widget_get_error_code(vc_error_e err) { switch (err) { - case VC_ERROR_NONE: return "VC_ERROR_NONE"; break; - case VC_ERROR_OUT_OF_MEMORY: return "VC_ERROR_OUT_OF_MEMORY"; break; - case VC_ERROR_IO_ERROR: return "VC_ERROR_IO_ERROR"; break; - case VC_ERROR_INVALID_PARAMETER:return "VC_ERROR_INVALID_PARAMETER"; break; - case VC_ERROR_TIMED_OUT: return "VC_ERROR_TIMED_OUT"; break; - case VC_ERROR_INVALID_STATE: return "VC_ERROR_INVALID_STATE"; break; - case VC_ERROR_ENGINE_NOT_FOUND: return "VC_ERROR_ENGINE_NOT_FOUND"; break; - case VC_ERROR_OPERATION_FAILED: return "VC_ERROR_OPERATION_FAILED"; break; - default: return "Invalid error code"; break; + case VC_ERROR_NONE: return "VC_ERROR_NONE"; break; + case VC_ERROR_OUT_OF_MEMORY: return "VC_ERROR_OUT_OF_MEMORY"; break; + case VC_ERROR_IO_ERROR: return "VC_ERROR_IO_ERROR"; break; + case VC_ERROR_INVALID_PARAMETER:return "VC_ERROR_INVALID_PARAMETER"; break; + case VC_ERROR_TIMED_OUT: return "VC_ERROR_TIMED_OUT"; break; + case VC_ERROR_INVALID_STATE: return "VC_ERROR_INVALID_STATE"; break; + case VC_ERROR_ENGINE_NOT_FOUND: return "VC_ERROR_ENGINE_NOT_FOUND"; break; + case VC_ERROR_OPERATION_FAILED: return "VC_ERROR_OPERATION_FAILED"; break; + default: return "Invalid error code"; break; } return NULL; } @@ -396,10 +396,10 @@ int vc_widget_get_state(vc_state_e* state) *state = temp; switch (*state) { - case VC_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCW, "Current state is 'None'"); break; - case VC_STATE_INITIALIZED: SLOG(LOG_DEBUG, TAG_VCW, "Current state is 'Created'"); break; - case VC_STATE_READY: SLOG(LOG_DEBUG, TAG_VCW, "Current state is 'Ready'"); break; - default: SLOG(LOG_ERROR, TAG_VCW, "Invalid state"); break; + case VC_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCW, "Current state is 'None'"); break; + case VC_STATE_INITIALIZED: SLOG(LOG_DEBUG, TAG_VCW, "Current state is 'Created'"); break; + case VC_STATE_READY: SLOG(LOG_DEBUG, TAG_VCW, "Current state is 'Ready'"); break; + default: SLOG(LOG_ERROR, TAG_VCW, "Invalid state"); break; } SLOG(LOG_DEBUG, TAG_VCW, "====="); @@ -442,11 +442,11 @@ int vc_widget_get_service_state(vc_service_state_e* state) *state = service_state; switch (*state) { - case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'None'"); break; - case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'Ready'"); break; - case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'Recording'"); break; - case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'Processing'"); break; - default: SLOG(LOG_ERROR, TAG_VCW, "Invalid service state"); break; + case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'None'"); break; + case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'Ready'"); break; + case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'Recording'"); break; + case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCW, "Current service state is 'Processing'"); break; + default: SLOG(LOG_ERROR, TAG_VCW, "Invalid service state"); break; } SLOG(LOG_DEBUG, TAG_VCW, "====="); -- 2.7.4 From 763f067da86e7f010df9d2f86367a95468c597c7 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 3 May 2016 13:41:04 +0900 Subject: [PATCH 16/16] change Tizen version for wearable Change-Id: I712947c1e207d8414b270570f44536008a5817ee Signed-off-by: sooyeon.kim --- client/vc.c | 2 +- common/vc_command.h | 10 ++++---- include/voice_control.h | 44 +++++++++++++++++----------------- include/voice_control_command.h | 40 +++++++++++++++---------------- include/voice_control_command_expand.h | 12 +++++----- include/voice_control_common.h | 20 ++++++++-------- include/voice_control_manager.h | 10 ++++---- include/voice_control_setting.h | 4 ++-- include/voice_control_widget.h | 2 +- 9 files changed, 72 insertions(+), 72 deletions(-) mode change 100644 => 100755 common/vc_command.h mode change 100644 => 100755 include/voice_control.h mode change 100644 => 100755 include/voice_control_command.h mode change 100644 => 100755 include/voice_control_command_expand.h mode change 100644 => 100755 include/voice_control_common.h mode change 100644 => 100755 include/voice_control_manager.h mode change 100644 => 100755 include/voice_control_setting.h mode change 100644 => 100755 include/voice_control_widget.h diff --git a/client/vc.c b/client/vc.c index e3161b6..1ee1350 100755 --- a/client/vc.c +++ b/client/vc.c @@ -806,7 +806,7 @@ int vc_get_window_id(int* wid) /** * @brief Checks whether the command format is supported. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] format The command format * @param[out] support The result status @c true = supported, @c false = not supported diff --git a/common/vc_command.h b/common/vc_command.h old mode 100644 new mode 100755 index 605edd6..b99e140 --- a/common/vc_command.h +++ b/common/vc_command.h @@ -48,7 +48,7 @@ typedef struct { /** * @brief Enumerations of command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { VC_COMMAND_TYPE_NONE = 0, /**< No command position */ @@ -68,7 +68,7 @@ int vc_cmd_print_list(vc_cmd_list_h vc_cmd_list); /** * @brief Remove all commands from command list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @param[in] free_command The command free option @c true = release each commands in list, @@ -86,7 +86,7 @@ int vc_cmd_list_remove_all(vc_cmd_list_h vc_cmd_list, bool free_command); /** * @brief Sets extra unfixed command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[in] command The unfixed command @@ -103,7 +103,7 @@ int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command); /** * @brief Sets pid. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[in] pid process id @@ -118,7 +118,7 @@ int vc_cmd_set_pid(vc_cmd_h vc_command, int pid); /** * @brief Sets command domain -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[in] domain domain diff --git a/include/voice_control.h b/include/voice_control.h old mode 100644 new mode 100755 index 8e7b5f3..8bf4d15 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -48,20 +48,20 @@ extern "C" /** * @brief Definitions for foreground command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_FOREGROUND 1 /** * @brief Definitions for background command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_BACKGROUND 2 /** * @brief Initializes voice control. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -82,7 +82,7 @@ int vc_initialize(void); /** * @brief Deinitializes voice control. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -99,7 +99,7 @@ int vc_deinitialize(void); /** * @brief Connects the voice control service. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -119,7 +119,7 @@ int vc_prepare(void); /** * @brief Disconnects the voice control service. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -138,7 +138,7 @@ int vc_unprepare(void); /** * @brief Retrieves all supported languages using callback function. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -163,7 +163,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user /** * @brief Gets current language. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -190,7 +190,7 @@ int vc_get_current_language(char** language); /** * @brief Gets current state of voice control client. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -209,7 +209,7 @@ int vc_get_state(vc_state_e* state); /** * @brief Gets current state of voice control service. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -233,7 +233,7 @@ int vc_get_service_state(vc_service_state_e* state); /** * @brief Sets command list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -258,7 +258,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type); /** * @brief Unsets command list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -280,7 +280,7 @@ int vc_unset_command_list(int type); /** * @brief Registers a callback function for getting recognition result. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -303,7 +303,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data); /** * @brief Unregisters the callback function. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -320,7 +320,7 @@ int vc_unset_result_cb(void); /** * @brief Registers a callback function to be called when state is changed. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -343,7 +343,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* /** * @brief Unregisters the callback function. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -361,7 +361,7 @@ int vc_unset_service_state_changed_cb(void); /** * @brief Registers a callback function to be called when state is changed. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -384,7 +384,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data); /** * @brief Unregisters the callback function. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -402,7 +402,7 @@ int vc_unset_state_changed_cb(void); /** * @brief Registers a callback function to be called when current language is changed. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -425,7 +425,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, /** * @brief Unregisters the callback function. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -443,7 +443,7 @@ int vc_unset_current_language_changed_cb(void); /** * @brief Registers a callback function to be called when an error occurred. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -466,7 +466,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data); /** * @brief Unregisters the callback function. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * diff --git a/include/voice_control_command.h b/include/voice_control_command.h old mode 100644 new mode 100755 index afb7810..82a7849 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -37,19 +37,19 @@ extern "C" /** * @brief The voice command handle. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef struct vc_cmd_s* vc_cmd_h; /** * @brief The voice command list handle. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef struct vc_cmd_list_s* vc_cmd_list_h; /** * @brief Called to retrieve The commands in list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[in] user_data The user data passed from the foreach function @@ -64,7 +64,7 @@ typedef bool (*vc_cmd_list_cb)(vc_cmd_h vc_command, void* user_data); /** * @brief Creates a handle for command list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks If the function succeeds, @a The list handle must be released with vc_cmd_list_destroy(). * @@ -83,7 +83,7 @@ int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list); /** * @brief Destroys the handle for command list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @param[in] free_command The command free option @c true = release each commands in list, @@ -101,7 +101,7 @@ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool free_command); /** * @brief Gets command count of list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @param[out] count The count @@ -116,7 +116,7 @@ int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count); /** * @brief Adds command to command list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @param[in] vc_command The command handle @@ -133,7 +133,7 @@ int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); /** * @brief Removes command from command list. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @param[in] vc_command The command handle @@ -150,7 +150,7 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); /** * @brief Retrieves all commands of command list using callback function. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @param[in] callback Callback function to invoke @@ -170,7 +170,7 @@ int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callb /** * @brief Moves index to first command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @@ -187,7 +187,7 @@ int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list); /** * @brief Moves index to last command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @@ -204,7 +204,7 @@ int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list); /** * @brief Moves index to next command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @@ -222,7 +222,7 @@ int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list); /** * @brief Moves index to previous command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @@ -240,7 +240,7 @@ int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list); /** * @brief Get current command from command list by index. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_cmd_list The command list handle * @param[out] vc_command The command handle @@ -262,7 +262,7 @@ int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command); /** * @brief Creates a handle for command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks If the function succeeds, @a The command handle must be released * with vc_cmd_destroy() or vc_cmd_list_destroy(). @@ -283,7 +283,7 @@ int vc_cmd_create(vc_cmd_h* vc_command); /** * @brief Destroys the handle. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @@ -299,7 +299,7 @@ int vc_cmd_destroy(vc_cmd_h vc_command); /** * @brief Sets command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[in] command The command text @@ -316,7 +316,7 @@ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command); /** * @brief Gets command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remark If the function succeeds, @a command must be released with free() by you if they are not NULL. * @@ -335,7 +335,7 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command); /** * @brief Sets command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remark If you do not set the command type, the default value is -1. * You should set type if command is valid @@ -355,7 +355,7 @@ int vc_cmd_set_type(vc_cmd_h vc_command, int type); /** * @brief Gets command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[out] type The command type diff --git a/include/voice_control_command_expand.h b/include/voice_control_command_expand.h old mode 100644 new mode 100755 index 8200285..f767d83 --- a/include/voice_control_command_expand.h +++ b/include/voice_control_command_expand.h @@ -30,7 +30,7 @@ extern "C" /** * @brief Enumerations of command format. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { VC_CMD_FORMAT_FIXED = 0, /**< fixed command only */ @@ -42,7 +42,7 @@ typedef enum { /** * @brief Gets extra unfixed command. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remark If the function succeeds, @a The command must be released with free() by you if they are not NULL. * If you get the result command list in result callback and the command type of commands has non-fixed format, @@ -61,7 +61,7 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command); /** * @brief Sets command format. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[in] format The command format @@ -78,7 +78,7 @@ int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format); /** * @brief Gets command format. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remark If you do not set the format, the default format is #VC_CMD_FORMAT_FIXED. * @@ -97,7 +97,7 @@ int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format); /** * @brief Sets command domain -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[in] domain The domain @@ -114,7 +114,7 @@ int vc_cmd_set_domain(vc_cmd_h vc_command, int domain); /** * @brief Gets command domain. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] vc_command The command handle * @param[out] domain The domain diff --git a/include/voice_control_common.h b/include/voice_control_common.h old mode 100644 new mode 100755 index 5d52a04..5724437 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -32,7 +32,7 @@ extern "C" /** * @brief Enumerations of error codes. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { VC_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ @@ -54,7 +54,7 @@ typedef enum { /** * @brief Enumerations of result event. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { VC_RESULT_EVENT_RESULT_SUCCESS = 0, /**< Normal result */ @@ -63,7 +63,7 @@ typedef enum { /** * @brief Enumerations of service state. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { VC_SERVICE_STATE_NONE = 0, /**< 'None' state */ @@ -74,7 +74,7 @@ typedef enum { /** * @brief Enumerations of client state. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { VC_STATE_NONE = 0, /**< 'None' state */ @@ -85,7 +85,7 @@ typedef enum { /** * @brief Called when client gets the recognition result. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks If the duplicated commands are recognized, the event(e.g. #VC_RESULT_EVENT_REJECTED) of command may be rejected \n * for selecting command as priority. If you set similar or same commands or the recognized results are multi-results, @@ -104,7 +104,7 @@ typedef void (*vc_result_cb)(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, /** * @brief Called when default language is changed. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] previous Previous language * @param[in] current Current language @@ -118,7 +118,7 @@ typedef void (*vc_current_language_changed_cb)(const char* previous, const char* /** * @brief Called to retrieve supported language. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n * followed by ISO 639-1 for the two-letter language code. \n @@ -133,7 +133,7 @@ typedef bool (*vc_supported_language_cb)(const char* language, void* user_data); /** * @brief Called when the state of voice control client is changed. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] previous A previous state * @param[in] current A current state @@ -147,7 +147,7 @@ typedef void (*vc_state_changed_cb)(vc_state_e previous, vc_state_e current, voi /** * @brief Called when the state of voice control service is changed. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] previous A previous state * @param[in] current A current state @@ -161,7 +161,7 @@ typedef void (*vc_service_state_changed_cb)(vc_service_state_e previous, vc_serv /** * @brief Called when error occurred. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] reason The error type (e.g. #VC_ERROR_OUT_OF_MEMORY, #VC_ERROR_TIMED_OUT) * @param[in] user_data The user data passed from the callback registration function diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h old mode 100644 new mode 100755 index e1c96fa..80476c6 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -40,31 +40,31 @@ extern "C" /** * @brief Definitions for foreground command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_FOREGROUND 1 /** * @brief Definitions for background command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_BACKGROUND 2 /** * @brief Definitions for widget command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_WIDGET 3 /** * @brief Definitions for system command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_SYSTEM 4 /** * @brief Definitions for exclusive command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_EXCLUSIVE 5 diff --git a/include/voice_control_setting.h b/include/voice_control_setting.h old mode 100644 new mode 100755 index b5ea1e1..29b95bd --- a/include/voice_control_setting.h +++ b/include/voice_control_setting.h @@ -49,7 +49,7 @@ typedef void (*vc_setting_enabled_changed_cb)(bool enabled, void* user_data); /** * @brief Called to retrieve supported language. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n * followed by ISO 639-1 for the two-letter language code. \n @@ -64,7 +64,7 @@ typedef bool(*vc_setting_supported_language_cb)(const char* language, void* user /** * @brief Called when default language is changed. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param[in] previous Previous language * @param[in] current Current language diff --git a/include/voice_control_widget.h b/include/voice_control_widget.h old mode 100644 new mode 100755 index f9ecd2c..91ddf74 --- a/include/voice_control_widget.h +++ b/include/voice_control_widget.h @@ -35,7 +35,7 @@ extern "C" /** * @brief Definitions for widget command type. -* @since_tizen 2.4 +* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_WIDGET 3 -- 2.7.4