From 78098042809a1dcf538b751b3c320c6186d1f02b Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 9 Nov 2016 17:52:17 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/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 11/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 12/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 211fa9d3965a2c84bf4536b94f42674bc1dc4803 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 5 Dec 2016 13:24:14 +0900 Subject: [PATCH 13/16] Fix crash issue in vcd_dbus_server_is_system_command_valid Change-Id: I051aeaa8326fe6692e86f250bed8a9d0d83fbf37 Signed-off-by: sooyeon.kim --- server/vcd_dbus_server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c index dafeadb..e263cdd 100644 --- a/server/vcd_dbus_server.c +++ b/server/vcd_dbus_server.c @@ -1329,7 +1329,7 @@ int vcd_dbus_server_is_system_command_valid(DBusConnection* conn, DBusMessage* m dbus_error_free(&err); } else { SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd dialog : pid(%d)", pid); - vcd_server_is_system_command_valid(pid, &is_sys_cmd_valid); + ret = vcd_server_is_system_command_valid(pid, &is_sys_cmd_valid); } DBusMessage* reply; @@ -1338,7 +1338,7 @@ int vcd_dbus_server_is_system_command_valid(DBusConnection* conn, DBusMessage* m if (NULL != reply) { dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, - DBUS_TYPE_STRING, &is_sys_cmd_valid, + DBUS_TYPE_INT32, &is_sys_cmd_valid, DBUS_TYPE_INVALID); if (0 == ret) { -- 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 14/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 From 9454faed5a26d6f51314e04869cf617b895c4c92 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 5 Dec 2016 17:45:48 +0900 Subject: [PATCH 15/16] Fix crash issue when widget was already deinitialized Change-Id: I47ad17c7ff183cbce707bbf79d6f9a3a2c4437ff Signed-off-by: Wonnam Jang --- client/vc_widget.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/vc_widget.c b/client/vc_widget.c index 3089ab4..e8195f6 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -891,7 +891,11 @@ static Eina_Bool __vc_widget_start_recording(void *data) void* send_command_user_data = NULL; vc_cmd_list_h vc_cmd_list = NULL; - vc_widget_client_get_send_command_list_cb(g_vc_w, &send_command_list_cb, &send_command_user_data); + int ret = vc_widget_client_get_send_command_list_cb(g_vc_w, &send_command_list_cb, &send_command_user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[WARNING] Invalid client"); + return -1; + } if (NULL != send_command_list_cb) { vc_widget_client_use_callback(g_vc_w); -- 2.7.4 From 452b3baf16d787d18aa222e176182c8adc058331 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 7 Dec 2016 11:42:11 +0900 Subject: [PATCH 16/16] Enable msf recording Change-Id: Ie95d73f07519e52423751042bacbdf4adbaaa59c Signed-off-by: Kwangyoun Kim --- CMakeLists.txt | 2 +- client/vc_widget.c | 1 - packaging/voice-control.spec | 2 +- server/vcd_recorder.c | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index add3b74..bb246fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland - capi-network-bluetooth capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libtzplatform-config libxml-2.0 sqlite3 vconf #msfapi + capi-network-bluetooth capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libtzplatform-config libxml-2.0 sqlite3 vconf msfapi ) ELSE() pkg_check_modules(pkgs REQUIRED diff --git a/client/vc_widget.c b/client/vc_widget.c index e8195f6..fc32ff5 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -908,7 +908,6 @@ static Eina_Bool __vc_widget_start_recording(void *data) } bool widget_command = false; - int ret; if (NULL != vc_cmd_list) { vc_cmd_list_s* list = NULL; diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 321fa0e..a1e54b0 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -31,7 +31,7 @@ BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(sqlite3) %if "%{PRODUCT_TYPE}" == "TV" -#BuildRequires: pkgconfig(msfapi) #not be applied yet. +BuildRequires: pkgconfig(msfapi) %endif BuildRequires: pkgconfig(vconf) BuildRequires: cmake diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 78134fb..aa7f0b0 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -16,7 +16,7 @@ #ifdef TV_PRODUCT #define TV_BT_MODE -//#define TV_MSF_WIFI_MODE +#define TV_MSF_WIFI_MODE #endif #include -- 2.7.4