From 2b449313081f7e7fd255b09cd67f9c6166a0bf36 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 2 Nov 2016 17:21:26 +0900 Subject: [PATCH 01/16] Fix versions of new enums Change-Id: I4268e1bd9d78f14f067533bcb2b218934316090b Signed-off-by: sooyeon.kim --- common/vc_cmd_db.h | 2 +- include/voice_control_common.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/vc_cmd_db.h b/common/vc_cmd_db.h index c580ce2..b7a97df 100644 --- a/common/vc_cmd_db.h +++ b/common/vc_cmd_db.h @@ -40,7 +40,7 @@ typedef enum { VC_DB_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_DB_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_DB_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_DB_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018 /**< Service daemon reset @if MOBILE (Since 3.0) @endif */ + VC_DB_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018 /**< Service daemon reset (Since 3.0) */ } vc_db_error_e; typedef struct _deactivated_app_s { diff --git a/include/voice_control_common.h b/include/voice_control_common.h index 7352104..28cee37 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -50,10 +50,10 @@ typedef enum { VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset @if MOBILE (Since 3.0) @endif */ - VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In process to ready @if MOBILE (Since 3.0) @endif */ - VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In process to recording @if MOBILE (Since 3.0) @endif */ - VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In process to processing @if MOBILE (Since 3.0) @endif */ + VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In process to ready (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In process to recording (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In process to processing (Since 3.0) */ } vc_error_e; /** -- 2.7.4 From fab247c6f176db2dca6c0c7ef5eb095b07c30780 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Thu, 3 Nov 2016 09:47:44 +0900 Subject: [PATCH 02/16] Fix foreground check logic Change-Id: Iaa3669707d0ee7cc1b6820b56dd4f616ebddf0fe --- client/vc.c | 44 ++++++++++++++++++++++++++++---------------- client/vc_widget.c | 16 ++++++++++++++-- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/client/vc.c b/client/vc.c index 46ef551..8ea8acc 100644 --- a/client/vc.c +++ b/client/vc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,9 @@ static Ecore_Timer* g_connect_timer = NULL; +static Ecore_Event_Handler* g_focus_in_handler = NULL; +static Ecore_Event_Handler* g_focus_out_handler = NULL; + static vc_h g_vc = NULL; static int g_daemon_pid = 0; @@ -233,13 +237,12 @@ static Eina_Bool __notify_auth_changed_cb(void *data) return EINA_FALSE; } -static int __vc_app_state_changed_cb(int app_state, void *data) +static Eina_Bool __focus_changed_cb(void *data, int type, void *event) { - int ret = -1; - SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] app state changed"); + SLOG(LOG_DEBUG, TAG_VCC, "===== Focus changed"); - /* Set current pid */ - if (STATUS_VISIBLE == app_state) { + int ret; + if (ECORE_WL_EVENT_FOCUS_IN == type) { SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground"); ret = vc_dbus_set_foreground(getpid(), true); if (0 != ret) { @@ -262,8 +265,8 @@ static int __vc_app_state_changed_cb(int app_state, void *data) /* 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"); + } else if (ECORE_WL_EVENT_FOCUS_OUT == type) { + SLOG(LOG_DEBUG, TAG_VCW, "===== 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); @@ -286,13 +289,13 @@ static int __vc_app_state_changed_cb(int app_state, void *data) 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, "===== type(%d) is NOT valid", type); } SLOG(LOG_DEBUG, TAG_VCC, "====="); - SLOG(LOG_DEBUG, TAG_VCC, " "); + SLOG(LOG_DEBUG, TAG_VCC, ""); - return 0; + return ECORE_CALLBACK_RENEW; } int vc_initialize(void) @@ -378,6 +381,14 @@ static void __vc_internal_unprepare(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); } + if (NULL != g_focus_in_handler) { + ecore_event_handler_del(g_focus_in_handler); + g_focus_in_handler = NULL; + } + if (NULL != g_focus_out_handler) { + ecore_event_handler_del(g_focus_out_handler); + g_focus_out_handler = NULL; + } ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); if (0 != ret) @@ -492,13 +503,14 @@ static Eina_Bool __vc_connect_daemon(void *data) g_connect_timer = NULL; - 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"); - } + g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + + char appid[255] = {'\0',}; + aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); - int status = aul_app_get_status_bypid(getpid()); - if (STATUS_FOCUS == status || STATUS_VISIBLE == status) { + int status = aul_app_get_status(appid); + if (STATUS_FOCUS == status) { SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground"); ret = vc_dbus_set_foreground(getpid(), true); if (0 != ret) { diff --git a/client/vc_widget.c b/client/vc_widget.c index 6714f40..3089ab4 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -32,6 +32,9 @@ static Ecore_Timer* g_w_connect_timer = NULL; +static Ecore_Event_Handler* g_focus_in_handler = NULL; +static Ecore_Event_Handler* g_focus_out_handler = NULL; + static Ecore_Timer* g_w_start_timer = NULL; static Ecore_Timer* g_w_tooltip_timer = NULL; @@ -162,6 +165,15 @@ static void __vc_widget_internal_unprepare() SLOG(LOG_WARN, TAG_VCW, "[ERROR] Fail to request finalize : %s", __vc_widget_get_error_code(ret)); } + if (NULL != g_focus_in_handler) { + ecore_event_handler_del(g_focus_in_handler); + g_focus_in_handler = NULL; + } + if (NULL != g_focus_out_handler) { + ecore_event_handler_del(g_focus_out_handler); + g_focus_out_handler = NULL; + } + ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_WIDGET); if (0 != ret) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_WIDGET, ret); @@ -286,8 +298,8 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) vc_widget_client_set_service_state(g_vc_w, (vc_service_state_e)service_state); - ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); - ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); char appid[255] = {'\0',}; aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); -- 2.7.4 From 69b680698c6e946fd93321c1a672e71e30282b8e Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Thu, 3 Nov 2016 10:49:25 +0900 Subject: [PATCH 03/16] Fix descriptions and Add documents for ACR-796 Change-Id: I2c5039dc69366223093313ff12333bff0ba91512 Signed-off-by: sooyeon.kim --- client/vc.c | 2 +- common/vc_command.c | 9 --------- common/vc_command.h | 16 --------------- doc/uix_vc_doc.h | 29 +++++++++++++++++++++++--- include/voice_control.h | 20 +++++++++--------- include/voice_control_command.h | 37 +++++++++++++++++++++++++++++++--- include/voice_control_command_expand.h | 2 +- include/voice_control_common.h | 6 +++--- 8 files changed, 76 insertions(+), 45 deletions(-) diff --git a/client/vc.c b/client/vc.c index 8ea8acc..b87cf54 100644 --- a/client/vc.c +++ b/client/vc.c @@ -2048,7 +2048,7 @@ int vc_set_invocation_name(const char* name) return ret; } -int vc_dialog(const char* disp_text, const char* utt_text, bool auto_start) +int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start) { vc_state_e state; diff --git a/common/vc_command.c b/common/vc_command.c index c37287e..6a0c91d 100755 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -931,9 +931,6 @@ 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 (0 != __vc_cmd_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } if (NULL == vc_command || NULL == command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); @@ -1108,9 +1105,6 @@ int vc_cmd_set_format(vc_cmd_h vc_command, int format) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } - if (0 != __vc_cmd_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -1132,9 +1126,6 @@ int vc_cmd_get_format(vc_cmd_h vc_command, int* format) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } - if (0 != __vc_cmd_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } if (NULL == vc_command || NULL == format) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); diff --git a/common/vc_command.h b/common/vc_command.h index c010c65..9f0bad5 100644 --- a/common/vc_command.h +++ b/common/vc_command.h @@ -162,22 +162,6 @@ int vc_cmd_set_fixed_command(vc_cmd_h vc_command, const char* fixed); int vc_cmd_get_fixed_command(vc_cmd_h vc_command, char** fixed); /** -* @brief Gets fixed command -* @since_tizen 3.0 -* -* @param[in] vc_command The command handle -* @param[out] fixed Fixed command -* -* @return 0 on success, otherwise a negative error value -* @retval #VC_CMD_ERROR_NONE Successful -* @retval #VC_CMD_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #VC_CMD_ERROR_NOT_SUPPORTED Not supported feature -* -* @see vc_cmd_set_unfixed_command() -*/ -int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command); - -/** * @brief Sets invocation name. * @since_tizen 3.0 * diff --git a/doc/uix_vc_doc.h b/doc/uix_vc_doc.h index 5cb9861..621b7de 100644 --- a/doc/uix_vc_doc.h +++ b/doc/uix_vc_doc.h @@ -40,9 +40,12 @@ * 4-3. Set command and type for command handle
* 4-4. Add command handle to command list
* 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
+ * 6. Set an invocation name for an application
+ * 7. Get recognition results
+ * 8. Request the dialogue
+ * 9. If an application wants to finish voice control,
+ * 9-1. Destroy command and command list handle
+ * 9-2. Deinitialize
* * An application can obtain command handle from command list, and also get information from handle. * @@ -147,6 +150,16 @@ * * * + * vc_get_result() + * Ready + * + * + * + * vc_get_system_command_list() + * Ready + * + * + * * vc_set_command_list() * Ready * @@ -157,6 +170,16 @@ * * * + * vc_set_invocation_name() + * Ready + * + * + * + * vc_request_dialog() + * Ready + * + * + * * * vc_set_result_cb()
* vc_unset_result_cb()
diff --git a/include/voice_control.h b/include/voice_control.h index 4d9c51a..1adcfb7 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -269,16 +269,16 @@ int vc_get_service_state(vc_service_state_e* state); int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list); /** - * @brief Sets invocation name. + * @brief Sets the invocation name. * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * - * @remarks Invocation name is used to activate background commands. The invocation name can be set as the application name or some words. - * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set as "Tizen Sample". + * @remarks Invocation name is used to activate background commands. The invocation name can be the same as the application name or any other phrase. + * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set to "Tizen Sample". * In order to activate the background command, users can say "Tizen Sample, Play music". - * The invocation name is dependent on the setting language. For example, if the setting language is "en_US"(English), the invocation name is also "en_US". - * If the setting language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized. + * The invocation name is dependent on the current language. For example, if the current language is "en_US"(English), the invocation name is also "en_US". + * If the current language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized. * This function should be called before vc_set_command_list(). * * @param[in] name Invocation name that an application wants to be invoked by @@ -298,16 +298,18 @@ int vc_set_invocation_name(const char* name); /** * @brief Requests to start the dialogue. - * @details Using this function, the developer can transfer texts, for starting the dialogue, to the framework. - * There are two types of texts. One is a text for displaying, and the other is that for uttering. + * @details Using this function, the developer can request starting the dialogue to the framework. + * When the developer requests the dialogue, two types of texts, @a disp_text and @a utt_text, can be sent by this function. + * @a disp_text is a text for displaying, and @a utt_text is that for uttering. * For example, if @a disp_text is "October 10th" and @a utt_text is "Today is October 10th.", "October 10th" will be displayed on the screen and "Today is October 10th." will be spoken. - * Also, the developer can set whether the dialogue restarts automatically or not, using @a auto_start. + * Also, the developer can set whether the dialogue starts automatically or not, using @a auto_start. + * If the developer sets @a auto_start as @c true, the framework will start to record next speech and continue the dialogue. * * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * - * @remarks If @a auto_start is @c true, the recognition will start again. In this case, 4 times can be restarted. + * @remarks If @a auto_start is @c true, the recognition will start again. In this case, it can be restarted up to 4 times. * * @param[in] disp_text Text to be displayed on the screen * @param[in] utt_text Text to be spoken diff --git a/include/voice_control_command.h b/include/voice_control_command.h index 8a7ee52..17aa455 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -35,6 +35,37 @@ extern "C" /** + * @brief Definition for fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_FIXED 0 + +/** + * @brief Definition for fixed and variable fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_FIXED_AND_VFIXED 1 + +/** + * @brief Definition for variable fixed and fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_VFIXED_AND_FIXED 2 + +/** + * @brief Definition for fixed and non-fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_FIXED_AND_NONFIXED 3 + +/** + * @brief Definition for non-fixed and fixed command format + * @since_tizen 3.0 + */ +#define VC_CMD_FORMAT_NONFIXED_AND_FIXED 4 + + +/** * @brief The voice command handle. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ @@ -168,7 +199,7 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data); /** - * @brief Retrieves all commands on the system command list using callback function. + * @brief Retrieves all commands on the system command list using a callback function. * @since_tizen 3.0 * * @param[in] callback Callback function to invoke @@ -355,8 +386,8 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command); * @brief Gets the unfixed command. * @since_tizen 3.0 * - * @remark After this function is successfully conducted, the @a command must be released with free() if it is not NULL. - * If the command in @a vc_command is NULL, @a command will be also NULL. + * @remark If the function succeeds, the @a command must be released with free() if it is not NULL. + * If the command of the given @a vc_command is NULL (@a vc_command is NOT NULL), @a command will be also NULL. * This function should be used for commands which have non-fixed format. * * @param[in] vc_command The command handle diff --git a/include/voice_control_command_expand.h b/include/voice_control_command_expand.h index 2714301..62d83ad 100755 --- a/include/voice_control_command_expand.h +++ b/include/voice_control_command_expand.h @@ -33,7 +33,7 @@ extern "C" * @since_tizen 3.0 */ typedef enum { - VC_CMD_FORMAT_FIXED = 0, /**< fixed command only */ + VC_CMD_FORMAT_FIXED = 0, /**< Fixed command only */ VC_CMD_FORMAT_FIXED_AND_VFIXED, /**< Fixed + variable fixed command */ VC_CMD_FORMAT_VFIXED_AND_FIXED, /**< Variable fixed + fixed command */ VC_CMD_FORMAT_FIXED_AND_NONFIXED, /**< Fixed + non fixed command */ diff --git a/include/voice_control_common.h b/include/voice_control_common.h index 28cee37..c81f5df 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -51,9 +51,9 @@ typedef enum { VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In process to ready (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In process to recording (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In process to processing (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In progress to ready (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In progress to recording (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In progress to processing (Since 3.0) */ } vc_error_e; /** -- 2.7.4 From 78098042809a1dcf538b751b3c320c6186d1f02b Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 9 Nov 2016 17:52:17 +0900 Subject: [PATCH 04/16] Change the names of definitions in voice_control_command.h Change-Id: I7930bf445a98c59b3a9abc0345e3d48f55c4e3d9 Signed-off-by: sooyeon.kim --- client/vc_mgr.c | 12 ++++++------ include/voice_control_command.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index ab5c2f4..a78e2b5 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -627,12 +627,12 @@ int vc_mgr_is_command_format_supported(vc_cmd_format_e format, bool* support) } switch (format) { - case VC_CMD_FORMAT_FIXED: *support = true; break; - case VC_CMD_FORMAT_FIXED_AND_VFIXED: *support = true; break; - case VC_CMD_FORMAT_VFIXED_AND_FIXED: *support = true; break; - case VC_CMD_FORMAT_FIXED_AND_NONFIXED: *support = non_fixed_support; break; - case VC_CMD_FORMAT_NONFIXED_AND_FIXED: *support = non_fixed_support; break; - default: *support = false; break; + case VC_CMD_FORMAT_FIXED: *support = true; break; + case VC_CMD_FORMAT_FIXED_AND_VFIXED: *support = true; break; + case VC_CMD_FORMAT_VFIXED_AND_FIXED: *support = true; break; + case VC_CMD_FORMAT_FIXED_AND_NONFIXED: *support = non_fixed_support; break; + case VC_CMD_FORMAT_NONFIXED_AND_FIXED: *support = non_fixed_support; break; + default: *support = false; break; } SLOG(LOG_ERROR, TAG_VCM, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); diff --git a/include/voice_control_command.h b/include/voice_control_command.h index 17aa455..8073991 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -38,31 +38,31 @@ extern "C" * @brief Definition for fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_FIXED 0 +#define VC_COMMAND_FORMAT_FIXED 0 /** * @brief Definition for fixed and variable fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_FIXED_AND_VFIXED 1 +#define VC_COMMAND_FORMAT_FIXED_AND_VFIXED 1 /** * @brief Definition for variable fixed and fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_VFIXED_AND_FIXED 2 +#define VC_COMMAND_FORMAT_VFIXED_AND_FIXED 2 /** * @brief Definition for fixed and non-fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_FIXED_AND_NONFIXED 3 +#define VC_COMMAND_FORMAT_FIXED_AND_NONFIXED 3 /** * @brief Definition for non-fixed and fixed command format * @since_tizen 3.0 */ -#define VC_CMD_FORMAT_NONFIXED_AND_FIXED 4 +#define VC_COMMAND_FORMAT_NONFIXED_AND_FIXED 4 /** -- 2.7.4 From ea8f546e6a15072e769612d200e81b8cba2165fe Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Thu, 10 Nov 2016 12:03:47 +0900 Subject: [PATCH 05/16] Fix memory leak issue Change-Id: Ic31fc6bd4f4fa49e6ffac2bb165238f1c41c5293 Signed-off-by: Wonnam Jang --- common/vc_info_parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 83847cf..c4fc2d4 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -191,6 +191,7 @@ int vc_info_parser_get_demandable_clients(GSList** client_list) if (NULL == temp_client) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Memory alloc error!!"); + xmlFreeDoc(doc); return -1; } @@ -279,6 +280,7 @@ int vc_info_parser_set_demandable_client(const char* filepath) int ret = xmlSaveFormatFile(VC_RUNTIME_INFO_DEMANDABLE_LIST, doc, 1); SLOG(LOG_DEBUG, vc_info_tag(), "Save demandable file info : %d", ret); + xmlFreeDoc(doc); return 0; } @@ -561,6 +563,7 @@ int vc_info_parser_get_client_info(GSList** client_info_list) if (NULL == client) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Memory alloc error!!"); + xmlFreeDoc(doc); return -1; } -- 2.7.4 From f19a02ea84329a2cdc48fb275921651b79e795ac Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 14 Nov 2016 13:51:13 +0900 Subject: [PATCH 06/16] Remove an api in voice_control_command.h Change-Id: I6da638f55fbcad17165b1f38053c21472816be5d Signed-off-by: sooyeon.kim --- include/voice_control_command.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/include/voice_control_command.h b/include/voice_control_command.h index 8073991..a6b48b1 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -199,25 +199,6 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data); /** - * @brief Retrieves all commands on the system command list using a callback function. - * @since_tizen 3.0 - * - * @param[in] callback Callback function to invoke - * @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 Successful - * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #VC_ERROR_PERMISSION_DENIED Permission denied - * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * - * @post This function invokes vc_cmd_list_cb() for each command. - * - * @see vc_cmd_list_cb() - */ -int vc_cmd_list_foreach_system_command(vc_cmd_list_cb callback, void* user_data); - -/** * @brief Moves index to first command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * -- 2.7.4 From 664bbf903a3cf384c280863f6c78323b2e74fcea Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Mon, 14 Nov 2016 16:19:56 +0900 Subject: [PATCH 07/16] Add logic for updating when manager app is changed Change-Id: I3c327c48791a403009d65d19308583629caa808b --- client/vc.c | 10 ++++++++++ client/vc_dbus.c | 16 ++++++++++++++++ common/vc_defs.h | 1 + server/vcd_dbus.c | 33 +++++++++++++++++++++++++++++++++ server/vcd_dbus.h | 2 ++ server/vcd_server.c | 10 ++++++++-- 6 files changed, 70 insertions(+), 2 deletions(-) diff --git a/client/vc.c b/client/vc.c index b87cf54..537c336 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1793,6 +1793,16 @@ int __vc_cb_service_state(int state) return 0; } +int __vc_cb_manager_pid(int manager_pid) +{ + SLOG(LOG_DEBUG, TAG_VCC, "Manager pid is changed : %d", manager_pid); + + /* Save service state */ + vc_client_set_mgr_pid(g_vc, manager_pid); + + return 0; +} + int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 1cd3270..86dc65d 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -33,6 +33,8 @@ extern void __vc_cb_result(); extern int __vc_cb_service_state(int state); +extern int __vc_cb_manager_pid(int manager_pid); + static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) { @@ -119,6 +121,20 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_VCC, " "); } /* VCD_METHOD_RESULT */ + else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_SEND_MANAGER_PID)) { + int manager_pid = 0; + + dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &manager_pid, DBUS_TYPE_INVALID); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Get arguments error (%s)", err.message); + dbus_error_free(&err); + } + + SLOG(LOG_DEBUG, TAG_VCC, "<<<< manager pid is changed : %d", manager_pid); + + __vc_cb_manager_pid(manager_pid); + + } /* VCD_METHOD_SEND_MANAGER_PID */ else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCC, "===== Get Error"); diff --git a/common/vc_defs.h b/common/vc_defs.h index 7b6294d..5859338 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -70,6 +70,7 @@ extern "C" { #define VCD_METHOD_ERROR "vcd_method_error" #define VCD_METHOD_HELLO "vcd_method_hello" #define VCD_METHOD_SET_SERVICE_STATE "vcd_method_set_service_state" +#define VCD_METHOD_SEND_MANAGER_PID "vcd_method_send_manager_pid" /* Authority */ #if 0 diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 58f3bdf..e6a8aa6 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -430,6 +430,39 @@ int vcdc_send_service_state(vcd_state_e state) return 0; } +int vcdc_send_manager_pid(int manager_pid) +{ + DBusError err; + dbus_error_init(&err); + + DBusMessage* msg = NULL; + + /* Send to client */ + msg = dbus_message_new_signal( + VC_CLIENT_SERVICE_OBJECT_PATH, + VC_CLIENT_SERVICE_INTERFACE, + VCD_METHOD_SEND_MANAGER_PID); + + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + dbus_message_append_args(msg, DBUS_TYPE_INT32, &manager_pid, DBUS_TYPE_INVALID); + + if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); + return VCD_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCD, "<<<< Send manager pid to client : pid(%d)", manager_pid); + dbus_connection_flush(g_conn_sender); + } + + dbus_message_unref(msg); + + return 0; +} + int vcdc_send_dialog(int manger_pid, int pid, const char* disp_text, const char* utt_text, int continuous) { DBusError err; diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index a1abc46..45d251c 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -57,6 +57,8 @@ int vcdc_send_service_state(vcd_state_e state); int vcdc_send_dialog(int manger_pid, int pid, const char* disp_text, const char* utt_text, int continuous); +int vcdc_send_manager_pid(int manager_pid); + #ifdef __cplusplus } diff --git a/server/vcd_server.c b/server/vcd_server.c index 2baf934..ff49a3c 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -252,7 +252,7 @@ static int __vcd_activate_app_by_appcontrol(const char* appid) } // Sent launch request ret = app_control_send_launch_request(app_control, NULL, NULL); - if(APP_CONTROL_ERROR_NONE != ret) { + if (APP_CONTROL_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send launch request, ret(%d)", ret); return VCD_ERROR_OPERATION_FAILED; } @@ -1313,6 +1313,9 @@ int vcd_server_mgr_initialize(int pid) return VCD_ERROR_OPERATION_FAILED; } + if (0 != vcdc_send_manager_pid(pid)) + SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send manager pid"); + SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid); return VCD_ERROR_NONE; @@ -1329,6 +1332,9 @@ int vcd_server_mgr_finalize(int pid) /* Cancel recognition */ vcd_server_mgr_cancel(); + if (0 != vcdc_send_manager_pid(-1)) + SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send manager pid"); + /* Remove manager information */ if (0 != vcd_client_manager_unset()) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to delete client"); @@ -1926,7 +1932,7 @@ int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int } int ret = __vcd_server_launch_manager_app(); - if (0 != ret){ + if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), pid(%d), disp_text(%s), utt_text(%s), continue(%d)", vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous); return ret; } -- 2.7.4 From 2e9d814f00d2b868f3a6aace8fed1e9213121134 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 15 Nov 2016 16:25:59 +0900 Subject: [PATCH 08/16] Fix dbus send for requesting the dialogue Change-Id: I2e9eea93a4850a2a26775abc2a5577da192c5d27 Signed-off-by: sooyeon.kim (cherry picked from commit bb49e7d3d48a3ff0aff1c38827f15d51b11bed4e) --- client/vc_dbus.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 86dc65d..feffd98 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -817,6 +817,21 @@ int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, DBUS_TYPE_INT32, &tmp_continue, DBUS_TYPE_INVALID); + dbus_message_set_no_reply(msg, TRUE); + + if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { + SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCC, "[Dbus DEBUG] Success to Send"); + dbus_connection_flush(g_conn_sender); + } + + dbus_message_unref(msg); + + return 0; + +/* DBusError err; dbus_error_init(&err); @@ -855,6 +870,7 @@ int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, } return result; +*/ } int vc_dbus_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) -- 2.7.4 From 5553af07eddf655cfa6f07daf8d058a128df7f92 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 15 Nov 2016 21:28:18 +0900 Subject: [PATCH 09/16] Fix coding rule issue Change-Id: Ibaff504c0082da59e4c7c83ba1fd48739e613871 Signed-off-by: sooyeon.kim --- common/vc_cmd_db.c | 32 +++++++++++++++----------------- common/vc_json_parser.c | 2 +- include/voice_control_common.h | 2 +- include/voice_control_plugin_engine.h | 2 +- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 240928a..00c7ce4 100755 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -52,7 +52,7 @@ const char* vc_db_tag() * */ -#define FREE_MEM(X) {if (NULL != X) {free(X); X = NULL;}} +#define FREE_MEM(X) {if (NULL != X) {free(X); X = NULL; } } //#define DB_PATH tzplatform_mkpath(TZ_USER_DB, ".vc_info.db") @@ -65,14 +65,12 @@ static int __vc_db_transaction(const char* transaction) sqlite3_stmt* pStmt = NULL; int ret = sqlite3_prepare_v2(db_handle, transaction, -1, &pStmt, NULL); - if (ret != SQLITE_OK) - { + if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_prepare_v2: transaction(%s), ret(%d), err(%s)", transaction, ret, sqlite3_errmsg(db_handle)); return VC_DB_ERROR_OPERATION_FAILED; } - if (sqlite3_step(pStmt) != SQLITE_DONE) - { + if (sqlite3_step(pStmt) != SQLITE_DONE) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_step: transaction(%s), ret(%d), err(%s)", transaction, ret, sqlite3_errmsg(db_handle)); sqlite3_finalize(pStmt); return VC_DB_ERROR_OPERATION_FAILED; @@ -290,7 +288,7 @@ static int __vc_db_get_commands(int pid, vc_cmd_type_e type, GSList** cmd_list) SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); return VC_DB_ERROR_OPERATION_FAILED; } - if (VC_COMMAND_TYPE_BACKGROUND != type ) { + if (VC_COMMAND_TYPE_BACKGROUND != type) { ret = sqlite3_bind_int(stmt, 2, pid); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); @@ -1032,20 +1030,20 @@ int vc_db_initialize(void) } if (lstat(path, &stat) < 0) { - char buf_err[256]; - SLOG(LOG_ERROR, vc_db_tag(), "%s", strerror_r(errno, buf_err, sizeof (buf_err))); - if (db_handle) - db_util_close(db_handle); - db_handle = NULL; - return VC_DB_ERROR_OPERATION_FAILED; + char buf_err[256]; + SLOG(LOG_ERROR, vc_db_tag(), "%s", strerror_r(errno, buf_err, sizeof(buf_err))); + if (db_handle) + db_util_close(db_handle); + db_handle = NULL; + return VC_DB_ERROR_OPERATION_FAILED; } if (!S_ISREG(stat.st_mode)) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] S_ISREG failed"); - if (db_handle) - db_util_close(db_handle); - db_handle = NULL; - return VC_DB_ERROR_OPERATION_FAILED; + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] S_ISREG failed"); + if (db_handle) + db_util_close(db_handle); + db_handle = NULL; + return VC_DB_ERROR_OPERATION_FAILED; } if (!stat.st_size) { diff --git a/common/vc_json_parser.c b/common/vc_json_parser.c index 4c99231..748a607 100755 --- a/common/vc_json_parser.c +++ b/common/vc_json_parser.c @@ -328,7 +328,7 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to insert command into db, type(%s), command(%s)", temp_type, temp_text); if (NULL != cmd->command) free(cmd->command); - if (NULL != cmd->appid) free(cmd->appid); + if (NULL != cmd->appid) free(cmd->appid); if (NULL != cmd->invocation_name) free(cmd->invocation_name); free(temp_type); free(prev_appid); diff --git a/include/voice_control_common.h b/include/voice_control_common.h index c81f5df..c938da2 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -125,7 +125,7 @@ typedef void (*vc_current_language_changed_cb)(const char* previous, const char* * @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 + * followed by ISO 639-1 for the two-letter language code. \n * For example, "ko_KR" for Korean, "en_US" for American English. * @param[in] user_data The user data passed from the foreach function * diff --git a/include/voice_control_plugin_engine.h b/include/voice_control_plugin_engine.h index a9d573b..c6c3ab5 100644 --- a/include/voice_control_plugin_engine.h +++ b/include/voice_control_plugin_engine.h @@ -124,7 +124,7 @@ typedef enum { VCP_ASR_RESULT_EVENT_FINAL_RESULT = 0, VCP_ASR_RESULT_EVENT_PARTIAL_RESULT, VCP_ASR_RESULT_EVENT_ERROR -}vcp_asr_result_event_e; +} vcp_asr_result_event_e; /** * @brief A structure of handle for VC command -- 2.7.4 From 5789c923494833638d80d717392f59f8219c6677 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 21 Nov 2016 16:59:53 +0900 Subject: [PATCH 10/16] Fix API reference warning Change-Id: I0153a823ca0bea788e52bc4a76d05a2338ac5b88 Signed-off-by: sooyeon.kim --- include/voice_control_command.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/voice_control_command.h b/include/voice_control_command.h index a6b48b1..f4e5ff7 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -296,7 +296,7 @@ int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command); * @remarks If the function succeeds, @a The command handle must be released * with vc_cmd_destroy() or vc_cmd_list_destroy(). * You should set command and type if command is valid. - * The command format is set to #VC_CMD_FORMAT_FIXED by default and can be changed with vc_cmd_set_format(). + * The command format is set to #VC_COMMAND_FORMAT_FIXED by default and can be changed with vc_cmd_set_format(). * * @param[out] vc_command The command handle * @@ -423,7 +423,7 @@ int vc_cmd_get_type(vc_cmd_h vc_command, int* type); * @brief Sets the command format. * @since_tizen 3.0 * - * @remark The default format is #VC_CMD_FORMAT_FIXED. + * @remark The default format is #VC_COMMAND_FORMAT_FIXED. * * @param[in] vc_command The command handle * @param[in] format The command format @@ -442,7 +442,7 @@ int vc_cmd_set_format(vc_cmd_h vc_command, int format); * @brief Gets the command format. * @since_tizen 3.0 * - * @remark The default format is #VC_CMD_FORMAT_FIXED. + * @remark The default format is #VC_COMMAND_FORMAT_FIXED. * * @param[in] vc_command The command handle * @param[out] format The command format -- 2.7.4 From 15c3d83a25d11e8450deb3dbc4b8ea60b1e14b35 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 23 Nov 2016 09:36:41 +0900 Subject: [PATCH 11/16] Add codes to check that dbus connection is valid Change-Id: I085a64015e77c830d0778f802f3e4b0f6590e2b8 Signed-off-by: Wonnam Jang --- client/vc_dbus.c | 2 +- server/vcd_dbus.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- server/vcd_main.c | 2 ++ 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 1cd3270..a48fcdc 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -290,7 +290,7 @@ int vc_dbus_reconnect() { bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); - SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Sender(%s) Listener(%s)", + SLOG(LOG_WARN, TAG_VCC, "[DBUS] Sender(%s) Listener(%s)", sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); if (false == sender_connected || false == listener_connected) { diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 58f3bdf..cf3a011 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -56,8 +56,42 @@ static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e return dbus_message_new_method_call(service_name, object_path, target_if_name, method); } +int vcd_dbus_reconnect() +{ + bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); + bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); + SLOG(LOG_WARN, TAG_VCD, "[DBUS] Sender(%s) Listener(%s)", + sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); + + if (false == sender_connected || false == listener_connected) { + vcd_dbus_close_connection(); + + if (0 != vcd_dbus_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to reconnect"); + return -1; + } + + SLOG(LOG_DEBUG, TAG_VCD, "[DBUS] Reconnect"); + } + + return 0; +} + +static int __dbus_check() +{ + if (NULL == g_conn_sender) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection"); + return vcd_dbus_reconnect(); + } + return 0; +} + int vcdc_send_hello(int pid, vcd_client_type_e type) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusMessage* msg = NULL; if (VCD_CLIENT_TYPE_NORMAL == type) { @@ -118,6 +152,10 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) int vcdc_send_show_tooltip(int pid, bool show) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + if (0 > pid) { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] widget pid is NOT valid"); return -1; @@ -171,6 +209,10 @@ int vcdc_send_show_tooltip(int pid, bool show) int vcdc_send_set_volume(int manger_pid, float volume) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusMessage* msg = NULL; /* SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] Set volume (%f)", volume); */ @@ -209,6 +251,10 @@ int vcdc_send_set_volume(int manger_pid, float volume) int vcdc_send_result(int pid, int manager_pid, int cmd_type) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusMessage* msg = NULL; SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] Result command type(%d)", cmd_type); @@ -258,6 +304,10 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_result) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusError err; dbus_error_init(&err); @@ -287,6 +337,10 @@ int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_ int vcdc_send_result_to_manager(int manger_pid, int result_type) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusError err; dbus_error_init(&err); @@ -320,6 +374,10 @@ int vcdc_send_result_to_manager(int manger_pid, int result_type) int vcdc_send_speech_detected(int manger_pid) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusError err; dbus_error_init(&err); @@ -350,6 +408,10 @@ int vcdc_send_speech_detected(int manger_pid) int vcdc_send_service_state(vcd_state_e state) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusError err; dbus_error_init(&err); @@ -432,6 +494,10 @@ int vcdc_send_service_state(vcd_state_e state) int vcdc_send_dialog(int manger_pid, int pid, const char* disp_text, const char* utt_text, int continuous) { + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + DBusError err; dbus_error_init(&err); @@ -477,6 +543,10 @@ int vcdc_send_error_signal_to_manager(int manager_pid, int reason, char *err_msg return VCD_ERROR_INVALID_PARAMETER; } + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + int daemon_pid; DBusError err; dbus_error_init(&err); @@ -518,6 +588,10 @@ int vcdc_send_error_signal(int reason, char *err_msg) return VCD_ERROR_INVALID_PARAMETER; } + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + int daemon_pid; DBusError err; dbus_error_init(&err); @@ -833,4 +907,4 @@ int vcd_dbus_close_connection() g_conn_sender = NULL; return 0; -} \ No newline at end of file +} diff --git a/server/vcd_main.c b/server/vcd_main.c index f31ed91..2996ba0 100644 --- a/server/vcd_main.c +++ b/server/vcd_main.c @@ -36,11 +36,13 @@ int main(int argc, char** argv) if (0 != vcd_dbus_open_connection()) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); + ecore_shutdown(); return EXIT_FAILURE; } if (0 != vcd_initialize()) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize vc-daemon"); + ecore_shutdown(); return EXIT_FAILURE; } -- 2.7.4 From 0ac9108b4c4d35bfb4dda1bec099f6a0fabeba50 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 23 Nov 2016 09:42:32 +0900 Subject: [PATCH 12/16] Add logic for updating volume frequently Change-Id: I228c18ca14b132354ff7477a4f42112704b9b29b Signed-off-by: Wonnam Jang --- client/vc_mgr.c | 36 ++++++++++++++++++++++++++++++++++-- server/vcd_recorder.c | 2 +- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index a78e2b5..ba7f6e5 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -37,12 +37,18 @@ static Ecore_Timer* g_m_connect_timer = NULL; +static Ecore_Timer* g_m_set_volume_timer = NULL; + static vc_h g_vc_m = NULL; static GSList* g_demandable_client_list = NULL; static float g_volume_db = 0; +static float g_prev_volume_db = 0; + +static float g_cur_volume_db = 0; + static int g_daemon_pid = 0; static int g_feature_enabled = -1; @@ -1758,10 +1764,36 @@ int vc_mgr_cancel() return ret; } +static int g_cnt = 0; +static Eina_Bool __vc_mgr_set_volume(void* data) +{ + g_cnt++; + g_volume_db = g_prev_volume_db + (g_cur_volume_db - g_prev_volume_db) / 5 * g_cnt; + + SLOG(LOG_DEBUG, TAG_VCM, "Set volume (%f)(%f)", g_volume_db, g_cur_volume_db); + + if (0 == g_cnt % 5) { + return EINA_FALSE; + } + return EINA_TRUE; +} + int __vc_mgr_cb_set_volume(float volume) { - g_volume_db = volume; - SLOG(LOG_DEBUG, TAG_VCM, "Set volume (%f)", g_volume_db); + g_prev_volume_db = g_volume_db; + g_cur_volume_db = volume; + + g_volume_db = g_prev_volume_db + (g_cur_volume_db - g_prev_volume_db) / 5; + + SLOG(LOG_DEBUG, TAG_VCM, "Set volume (%f)(%f)", g_volume_db, g_cur_volume_db); + + if (NULL != g_m_set_volume_timer) { + SLOG(LOG_DEBUG, TAG_VCM, "Connect Timer is deleted"); + ecore_timer_del(g_m_set_volume_timer); + } + + g_cnt = 1; + g_m_set_volume_timer = ecore_timer_add(50, __vc_mgr_set_volume, NULL); return 0; } diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 9ffb34c..78134fb 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -160,7 +160,7 @@ static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void } /* Set volume */ - if (0 == g_buffer_count % 30) { + if (0 == g_buffer_count % 15) { 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); -- 2.7.4 From 0d6f7636e5a68e0431a84495a795c92562e40fd6 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 23 Nov 2016 19:53:40 +0900 Subject: [PATCH 13/16] Fix signal handling problem when app terminate Change-Id: Iae1fc20c5f11489804d1a1c3185d6ce8d8368d3f Signed-off-by: Wonnam Jang --- server/vcd_dbus.c | 11 ++++++++++- server/vcd_dbus.h | 1 + server/vcd_main.c | 2 ++ server/vcd_server.c | 20 ++++++++++++++++++-- server/vcd_server.h | 2 ++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index cf3a011..5bcd10f 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -79,13 +79,22 @@ int vcd_dbus_reconnect() static int __dbus_check() { - if (NULL == g_conn_sender) { + if (NULL == g_conn_sender || NULL == g_conn_listener) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection"); return vcd_dbus_reconnect(); } return 0; } +int vcd_check_dbus_connection() +{ + if (NULL == g_conn_sender || NULL == g_conn_listener) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection sender(%p), listener(%p)", g_conn_sender, g_conn_listener); + return -1; + } + return 0; +} + int vcdc_send_hello(int pid, vcd_client_type_e type) { if (0 != __dbus_check()) { diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index a1abc46..812e643 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -34,6 +34,7 @@ int vcd_dbus_open_connection(); int vcd_dbus_close_connection(); +int vcd_check_dbus_connection(); int vcdc_send_hello(int pid, vcd_client_type_e type); diff --git a/server/vcd_main.c b/server/vcd_main.c index 2996ba0..903ff3f 100644 --- a/server/vcd_main.c +++ b/server/vcd_main.c @@ -67,6 +67,8 @@ int main(int argc, char** argv) vcd_finalize(); + vcd_unregister_signal(); + vcd_dbus_close_connection(); ecore_shutdown(); diff --git a/server/vcd_server.c b/server/vcd_server.c index 2baf934..24fda25 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -919,9 +919,12 @@ static void __sig_handler(int signo) { /* restore signal handler */ signal(signo, SIG_DFL); + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR]"); - /* Send error signal for notifying that daemon is reset*/ - vcdc_send_error_signal(VCD_ERROR_SERVICE_RESET, "Daemon reset"); + if (0 == vcd_check_dbus_connection()) { + /* Send error signal for notifying that daemon is reset*/ + vcdc_send_error_signal(VCD_ERROR_SERVICE_RESET, "Daemon reset"); + } /* invoke signal again */ raise(signo); @@ -934,6 +937,19 @@ static void __register_sig_handler() signal(SIGTERM, __sig_handler); signal(SIGINT, __sig_handler); signal(SIGQUIT, __sig_handler); + signal(SIGILL, __sig_handler); + signal(SIGBUS, __sig_handler); +} + +void vcd_unregister_signal() +{ + signal(SIGSEGV, SIG_IGN); + signal(SIGABRT, SIG_IGN); + signal(SIGTERM, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGILL, SIG_IGN); + signal(SIGBUS, SIG_IGN); } int vcd_initialize() diff --git a/server/vcd_server.h b/server/vcd_server.h index 5166ccb..72a51db 100644 --- a/server/vcd_server.h +++ b/server/vcd_server.h @@ -32,6 +32,8 @@ int vcd_initialize(); void vcd_finalize(); +void vcd_unregister_signal(); + Eina_Bool vcd_cleanup_client_all(void *data); int vcd_server_get_service_state(); -- 2.7.4 From 139b9de7ca6d9bdaef81b286813c18bb9ce0b58e Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Thu, 24 Nov 2016 18:10:03 +0900 Subject: [PATCH 14/16] Fix update volume Change-Id: I2c95a2940aa015c3c94d97c76cf115d3ce65f778 Signed-off-by: Wonnam Jang --- client/vc_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index ba7f6e5..4dfe493 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -1793,7 +1793,7 @@ int __vc_mgr_cb_set_volume(float volume) } g_cnt = 1; - g_m_set_volume_timer = ecore_timer_add(50, __vc_mgr_set_volume, NULL); + g_m_set_volume_timer = ecore_timer_add(0.05, __vc_mgr_set_volume, NULL); return 0; } -- 2.7.4 From e9f754b51e4551c345cf1e7117748be59826a71b Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Mon, 28 Nov 2016 15:12:09 +0900 Subject: [PATCH 15/16] Add dbus signal handling for daemon exeption Change-Id: I52dd071b3b063d13923b434d60ff219254777f2f Signed-off-by: Kwangyoun Kim --- client/vc_dbus.c | 37 ++++++++++++++++++++++++++++++++++--- client/vc_mgr_dbus.c | 31 +++++++++++++++++++++++++++++++ client/vc_widget_dbus.c | 38 +++++++++++++++++++++++++++++++++++--- server/vcd_main.c | 2 -- server/vcd_server.c | 39 --------------------------------------- server/vcd_server.h | 2 -- 6 files changed, 100 insertions(+), 49 deletions(-) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index d221b6a..f7af5f9 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -160,6 +160,13 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_VCC, " "); } /* VCD_METHOD_ERROR */ + else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) { + SLOG(LOG_DEBUG, TAG_VCC, "===== Owner Changed"); + __vc_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset"); + SLOG(LOG_DEBUG, TAG_VCC, "====="); + SLOG(LOG_DEBUG, TAG_VCC, " "); + } /* NameOwnerChanged */ + else { SLOG(LOG_DEBUG, TAG_VCC, "Message is NOT valid"); dbus_message_unref(msg); @@ -438,6 +445,19 @@ int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* d *mgr_pid = tmp; *service_state = tmp_service_state; *daemon_pid = tmp_daemon_pid; + + /* add a rule for daemon error */ + char rule_err[256] = {0, }; + snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + dbus_bus_add_match(g_conn_listener, rule_err, &err); + dbus_connection_flush(g_conn_listener); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); + dbus_error_free(&err); + return VC_ERROR_OPERATION_FAILED; + } + SLOG(LOG_DEBUG, TAG_VCC, "<<<< vc initialize : result = %d mgr = %d service = %d daemon_pid = %d", result, *mgr_pid, *service_state, *daemon_pid); } else { SLOG(LOG_ERROR, TAG_VCC, "<<<< vc initialize : result = %d", result); @@ -453,10 +473,24 @@ int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* d int vc_dbus_request_finalize(int pid) { + DBusError err; + dbus_error_init(&err); + if (0 != __dbus_check()) { return VC_ERROR_OPERATION_FAILED; } + /* remove a rule for daemon error */ + char rule_err[256] = {0, }; + snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + dbus_bus_remove_match(g_conn_listener, rule_err, &err); + dbus_connection_flush(g_conn_listener); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); + dbus_error_free(&err); + } + DBusMessage* msg; msg = dbus_message_new_method_call( @@ -474,9 +508,6 @@ int vc_dbus_request_finalize(int pid) dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - DBusError err; - dbus_error_init(&err); - DBusMessage* result_msg; int result = VC_ERROR_OPERATION_FAILED; diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 9c70c07..93cbb17 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -463,6 +463,13 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCM, " "); } /* VC_METHOD_AUTH_CANCEL */ + else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) { + SLOG(LOG_DEBUG, TAG_VCM, "===== Owner Changed"); + __vc_mgr_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset"); + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + } /* NameOwnerChanged */ + else { SLOG(LOG_DEBUG, TAG_VCM, "Message is NOT valid"); dbus_message_unref(msg); @@ -762,6 +769,18 @@ int vc_mgr_dbus_request_initialize(int pid, int* service_state, int* foreground, *service_state = tmp_service_state; *foreground = tmp_foreground; *daemon_pid = tmp_daemon_pid; + + /* add a rule for daemon error */ + char rule_err[256] = {0, }; + snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + dbus_bus_add_match(g_m_conn_listener, rule_err, &err); + dbus_connection_flush(g_m_conn_listener); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); + dbus_error_free(&err); + } + SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc mgr initialize : result = %d, service state = %d, foreground = %d, daemon_pid = %d", result, *service_state, *foreground, *daemon_pid); } else { @@ -797,6 +816,18 @@ int vc_mgr_dbus_request_finalize(int pid) return VC_ERROR_OPERATION_FAILED; } + /* remove a rule for daemon error */ + char rule_err[256] = {0, }; + snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + dbus_bus_remove_match(g_m_conn_listener, rule_err, &err); + dbus_connection_flush(g_m_conn_listener); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); + dbus_error_free(&err); + return VC_ERROR_OPERATION_FAILED; + } + DBusMessage* msg; msg = dbus_message_new_method_call( diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index a449df4..d491393 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -206,6 +206,13 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd SLOG(LOG_DEBUG, TAG_VCW, " "); } /* VCD_WIDGET_METHOD_ERROR */ + else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Owner Changed"); + __vc_widget_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset"); + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, " "); + } /* NameOwnerChanged */ + else { SLOG(LOG_ERROR, TAG_VCW, "Message is NOT valid"); dbus_message_unref(msg); @@ -465,6 +472,19 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p if (0 == result) { *service_state = tmp_service_state; *daemon_pid = tmp_daemon_pid; + + /* add a rule for daemon error */ + char rule_err[256] = {0, }; + snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + dbus_bus_add_match(g_w_conn_listener, rule_err, &err); + dbus_connection_flush(g_w_conn_listener); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message); + dbus_error_free(&err); + return VC_ERROR_OPERATION_FAILED; + } + SLOG(LOG_DEBUG, TAG_VCW, "<<<< vc widget initialize : result = %d service = %d daemon_pid = %d", result, *service_state, *daemon_pid); } else { SLOG(LOG_ERROR, TAG_VCW, "<<<< vc widget initialize : result = %d", result); @@ -480,6 +500,21 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p int vc_widget_dbus_request_finalize(int pid) { + DBusError err; + dbus_error_init(&err); + + /* remove a rule for daemon error */ + char rule_err[256] = {0, }; + snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + dbus_bus_remove_match(g_w_conn_listener, rule_err, &err); + dbus_connection_flush(g_w_conn_listener); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message); + dbus_error_free(&err); + return VC_ERROR_OPERATION_FAILED; + } + DBusMessage* msg; msg = dbus_message_new_method_call( @@ -497,9 +532,6 @@ int vc_widget_dbus_request_finalize(int pid) dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - DBusError err; - dbus_error_init(&err); - DBusMessage* result_msg; int result = VC_ERROR_OPERATION_FAILED; diff --git a/server/vcd_main.c b/server/vcd_main.c index 903ff3f..2996ba0 100644 --- a/server/vcd_main.c +++ b/server/vcd_main.c @@ -67,8 +67,6 @@ int main(int argc, char** argv) vcd_finalize(); - vcd_unregister_signal(); - vcd_dbus_close_connection(); ecore_shutdown(); diff --git a/server/vcd_server.c b/server/vcd_server.c index 2076a30..41f225e 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -915,49 +915,10 @@ static int __vcd_db_clean_up() return ret; } -static void __sig_handler(int signo) -{ - /* restore signal handler */ - signal(signo, SIG_DFL); - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR]"); - - if (0 == vcd_check_dbus_connection()) { - /* Send error signal for notifying that daemon is reset*/ - vcdc_send_error_signal(VCD_ERROR_SERVICE_RESET, "Daemon reset"); - } - - /* invoke signal again */ - raise(signo); -} - -static void __register_sig_handler() -{ - signal(SIGSEGV, __sig_handler); - signal(SIGABRT, __sig_handler); - signal(SIGTERM, __sig_handler); - signal(SIGINT, __sig_handler); - signal(SIGQUIT, __sig_handler); - signal(SIGILL, __sig_handler); - signal(SIGBUS, __sig_handler); -} - -void vcd_unregister_signal() -{ - signal(SIGSEGV, SIG_IGN); - signal(SIGABRT, SIG_IGN); - signal(SIGTERM, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGILL, SIG_IGN); - signal(SIGBUS, SIG_IGN); -} - int vcd_initialize() { int ret = 0; - __register_sig_handler(); - /* Remove old file */ __vcd_file_clean_up(); diff --git a/server/vcd_server.h b/server/vcd_server.h index 72a51db..5166ccb 100644 --- a/server/vcd_server.h +++ b/server/vcd_server.h @@ -32,8 +32,6 @@ int vcd_initialize(); void vcd_finalize(); -void vcd_unregister_signal(); - Eina_Bool vcd_cleanup_client_all(void *data); int vcd_server_get_service_state(); -- 2.7.4 From d9d12f640b9a5b60952f403ee796f4e168ccc6c3 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 5 Dec 2016 11:14:43 +0900 Subject: [PATCH 16/16] Fix invocation name problem after crash Change-Id: I3930fe28d9891470db2c8e878480c06deedf1fdd Signed-off-by: Wonnam Jang --- common/vc_cmd_db.c | 86 ++++++++++++++++++++++++++++++++++++++++++++--------- common/vc_command.c | 24 +++++++++++++-- 2 files changed, 93 insertions(+), 17 deletions(-) mode change 100755 => 100644 common/vc_cmd_db.c diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c old mode 100755 new mode 100644 index 00c7ce4..aa19fc0 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1005,6 +1005,60 @@ static int __vc_db_append_commands(int pid, int type, vc_cmd_list_h vc_cmd_list) return VC_DB_ERROR_NONE; } +static vc_cmd_s* __vc_db_command_copy(vc_cmd_s* src_cmd) +{ + if (NULL == src_cmd) { + SLOG(LOG_WARN, vc_db_tag(), "[Client Data] Input command is NULL"); + return NULL; + } + + vc_cmd_s* temp_cmd = NULL; + temp_cmd = (vc_cmd_s*)calloc(sizeof(vc_cmd_s), 1); + if (NULL == temp_cmd) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to allocate memory"); + return NULL; + } + + temp_cmd->id = src_cmd->id; + temp_cmd->pid = src_cmd->pid; + temp_cmd->index = src_cmd->index; + temp_cmd->type = src_cmd->type; + temp_cmd->format = src_cmd->format; + temp_cmd->domain = src_cmd->domain; + + if (VC_COMMAND_TYPE_SYSTEM == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_SYSTEM; + else if (VC_COMMAND_TYPE_EXCLUSIVE == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_EXCLUSIVE; + else if (VC_COMMAND_TYPE_FOREGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_FOREGROUND; + else if (VC_COMMAND_TYPE_WIDGET == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_FOREGROUND; + else if (VC_COMMAND_TYPE_SYSTEM_BACKGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_SYSTEM_BACKGROUND; + else if (VC_COMMAND_TYPE_BACKGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_BACKGROUND; + + if (NULL != src_cmd->command) { + temp_cmd->command = strdup(src_cmd->command); + } + + if (NULL != src_cmd->parameter) { + temp_cmd->parameter = strdup(src_cmd->parameter); + } + + if (NULL != src_cmd->appid) { + temp_cmd->appid = strdup(src_cmd->appid); + } + + if (NULL != src_cmd->invocation_name) { + temp_cmd->invocation_name = strdup(src_cmd->invocation_name); + } + + if (NULL != src_cmd->fixed) { + temp_cmd->fixed = strdup(src_cmd->fixed); + } + + temp_cmd->key = src_cmd->key; + temp_cmd->modifier = src_cmd->modifier; + + return temp_cmd; +} + int vc_db_initialize(void) { SLOG(LOG_ERROR, vc_db_tag(), "DB initialization"); @@ -1322,8 +1376,9 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) { GSList* cmd_list = NULL; char* fixed_cmd = NULL; + vc_cmd_s* tmp_cmd = __vc_db_command_copy(cmd); - int ret = __vc_db_generate_command(cmd, &fixed_cmd, &cmd_list); + int ret = __vc_db_generate_command(tmp_cmd, &fixed_cmd, &cmd_list); if (0 != ret) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to generate command, %d", ret); return ret; @@ -1338,39 +1393,41 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) temp_command = iter->data; if (NULL != temp_command) { - if (NULL != cmd->command) { - free(cmd->command); - cmd->command = NULL; + if (NULL != tmp_cmd->command) { + free(tmp_cmd->command); + tmp_cmd->command = NULL; } - cmd->command = strdup(temp_command); + tmp_cmd->command = strdup(temp_command); if (NULL != fixed_cmd) - cmd->fixed = strdup(fixed_cmd); + tmp_cmd->fixed = strdup(fixed_cmd); else - cmd->fixed = NULL; + tmp_cmd->fixed = NULL; - int ret = __vc_db_insert_commands(pid, type, cmd); + int ret = __vc_db_insert_commands(pid, type, tmp_cmd); if (ret != VC_DB_ERROR_NONE) { if (NULL != fixed_cmd) { free(fixed_cmd); fixed_cmd = NULL; } + vc_cmd_destroy((vc_cmd_h)tmp_cmd); return ret; } - if (VC_COMMAND_TYPE_BACKGROUND == type && NULL != cmd->invocation_name) { + if (VC_COMMAND_TYPE_BACKGROUND == type && NULL != tmp_cmd->invocation_name) { char temp[256] = {0, }; - snprintf(temp, 256, "%s %s", cmd->invocation_name, cmd->command); - if (NULL != cmd->command) - free(cmd->command); + snprintf(temp, 256, "%s %s", tmp_cmd->invocation_name, tmp_cmd->command); + if (NULL != tmp_cmd->command) + free(tmp_cmd->command); - cmd->command = strdup(temp); + tmp_cmd->command = strdup(temp); - ret = __vc_db_insert_commands(pid, type, cmd); + ret = __vc_db_insert_commands(pid, type, tmp_cmd); if (ret != VC_DB_ERROR_NONE) { if (NULL != fixed_cmd) { free(fixed_cmd); fixed_cmd = NULL; } + vc_cmd_destroy((vc_cmd_h)tmp_cmd); return ret; } } @@ -1389,6 +1446,7 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) free(fixed_cmd); fixed_cmd = NULL; } + vc_cmd_destroy((vc_cmd_h)tmp_cmd); return VC_DB_ERROR_NONE; } diff --git a/common/vc_command.c b/common/vc_command.c index 6a0c91d..b085344 100755 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -726,8 +726,26 @@ int vc_cmd_destroy(vc_cmd_h vc_command) SLOG(LOG_DEBUG, TAG_VCCMD, "[Destroy command][%p]", command); if (NULL != command) { - if (NULL != command->command) free(command->command); - if (NULL != command->parameter) free(command->parameter); + if (NULL != command->command) { + free(command->command); + command->command = NULL; + } + if (NULL != command->parameter) { + free(command->parameter); + command->parameter = NULL; + } + if (NULL != command->invocation_name) { + free(command->invocation_name); + command->invocation_name = NULL; + } + if (NULL != command->appid) { + free(command->appid); + command->appid = NULL; + } + if (NULL != command->fixed) { + free(command->fixed); + command->fixed = NULL; + } free(command); command = NULL; } @@ -1816,7 +1834,7 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) hour = hour + 12 * flag; if (12 == hour) hour = 0; - else if(24 == hour) hour = 12; + else if (24 == hour) hour = 12; } if (0 > hour || 24 <= hour || (0 == flag && 12 < hour)) { -- 2.7.4