From 2e9d814f00d2b868f3a6aace8fed1e9213121134 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 15 Nov 2016 16:25:59 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/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 11/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 ad35182f170d909d16fcdf65310f8aa047e89492 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 5 Dec 2016 19:26:12 +0900 Subject: [PATCH 12/16] Change log level from error to info Change-Id: Ifaef2e1679d4085f51949608447d70d1e80a4f00 Signed-off-by: Wonnam Jang --- client/vc.c | 7 ++++--- client/vc_mgr.c | 1 + client/vc_widget.c | 5 +++-- common/vc_cmd_db.c | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/client/vc.c b/client/vc.c index 537c336..fafc574 100644 --- a/client/vc.c +++ b/client/vc.c @@ -427,6 +427,7 @@ int vc_deinitialize(void) if (NULL != g_connect_timer) { SLOG(LOG_DEBUG, TAG_VCC, "Connect Timer is deleted"); ecore_timer_del(g_connect_timer); + g_connect_timer = NULL; } vc_config_mgr_unset_lang_cb(g_vc->handle); @@ -470,6 +471,8 @@ static Eina_Bool __vc_connect_daemon(void *data) int mgr_pid = -1; int service_state = 0; + g_connect_timer = NULL; + ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); if (0 != ret) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); @@ -501,8 +504,6 @@ static Eina_Bool __vc_connect_daemon(void *data) /* Set service state */ vc_client_set_service_state(g_vc, (vc_service_state_e)service_state); - g_connect_timer = 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); @@ -716,7 +717,7 @@ int vc_get_state(vc_state_e* state) vc_state_e temp; if (0 != vc_client_get_client_state(g_vc, &temp)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not valid"); SLOG(LOG_DEBUG, TAG_VCC, "====="); SLOG(LOG_DEBUG, TAG_VCC, " "); return VC_ERROR_INVALID_STATE; diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 4dfe493..7143a67 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -213,6 +213,7 @@ int vc_mgr_deinitialize() if (NULL != g_m_connect_timer) { SLOG(LOG_DEBUG, TAG_VCM, "Connect Timer is deleted"); ecore_timer_del(g_m_connect_timer); + g_m_connect_timer = NULL; } vc_config_mgr_unset_lang_cb(g_vc_m->handle + VC_MANAGER_CONFIG_HANDLE); diff --git a/client/vc_widget.c b/client/vc_widget.c index e8195f6..a8b1357 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -204,6 +204,7 @@ int vc_widget_deinitialize() if (NULL != g_w_connect_timer) { SLOG(LOG_DEBUG, TAG_VCW, "Connect Timer is deleted"); ecore_timer_del(g_w_connect_timer); + g_w_connect_timer = NULL; } vc_config_mgr_unset_lang_cb(g_vc_w->handle + VC_WIDGET_CONFIG_HANDLE); @@ -270,6 +271,8 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Connect daemon"); + g_w_connect_timer = NULL; + /* request initialization */ int ret = -1; int service_state = 0; @@ -316,8 +319,6 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) vc_widget_client_set_state(g_vc_w, VC_STATE_READY); ecore_timer_add(0, __vc_widget_notify_state_changed, g_vc_w); - g_w_connect_timer = NULL; - SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index aa19fc0..5ed395c 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -246,8 +246,8 @@ static int __vc_db_insert_commands(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) return VC_DB_ERROR_OPERATION_FAILED; } - SLOG(LOG_ERROR, vc_db_tag(), "[SQL] INSERT INTO vc_info (id, pid(%d), type(%d), format(%d), domain(%d), command(%s)", pid, cmd->type, cmd->format, cmd->domain, cmd->command); - SLOG(LOG_ERROR, vc_db_tag(), "[SQL] ==== appid(%s), invocation(%s), fixed(%s)", cmd->appid, cmd->invocation_name, cmd->fixed); + SLOG(LOG_INFO, vc_db_tag(), "[SQL] INSERT INTO vc_info (id, pid(%d), type(%d), format(%d), domain(%d), command(%s)", pid, cmd->type, cmd->format, cmd->domain, cmd->command); + SLOG(LOG_INFO, vc_db_tag(), "[SQL] ==== appid(%s), invocation(%s), fixed(%s)", cmd->appid, cmd->invocation_name, cmd->fixed); sqlite3_reset(stmt); sqlite3_clear_bindings(stmt); @@ -1061,7 +1061,7 @@ static vc_cmd_s* __vc_db_command_copy(vc_cmd_s* src_cmd) int vc_db_initialize(void) { - SLOG(LOG_ERROR, vc_db_tag(), "DB initialization"); + SLOG(LOG_INFO, vc_db_tag(), "DB initialization"); path = (char*)calloc(256, sizeof(char)); if (NULL == path) { -- 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 13/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 From 366eb888415f30b8c00610991760a6e91d1b39f4 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 13 Dec 2016 17:16:58 +0900 Subject: [PATCH 14/16] Fix log tag in result cb(LOG_DEBUG -> LOG_INFO) Change-Id: I09e5cf6e5afa0cc60a7217010bcc3347aac3a86b Signed-off-by: Suyeon Hwang --- client/vc.c | 4 ++-- client/vc_mgr.c | 6 +++--- client/vc_widget.c | 4 ++-- server/vcd_server.c | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/vc.c b/client/vc.c index 537c336..008396c 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1628,7 +1628,7 @@ static Eina_Bool __vc_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCC, "Result info : result text(%s) event(%d)", temp_text, event); + SLOG(LOG_INFO, TAG_VCC, "Result info : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); @@ -1636,7 +1636,7 @@ static Eina_Bool __vc_notify_result(void *data) callback(event, vc_cmd_list, temp_text, user_data); vc_client_not_use_callback(g_vc); - SLOG(LOG_DEBUG, TAG_VCC, "Client result callback called"); + SLOG(LOG_INFO, TAG_VCC, "Client result callback called"); vc_cmd_list_destroy(vc_cmd_list, true); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 4dfe493..791de02 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -1954,7 +1954,7 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) vc_info_parser_get_result(&temp_text, &event, &temp_message, -1, vc_cmd_list, vc_mgr_client_get_exclusive_command(g_vc_m)); - SLOG(LOG_DEBUG, TAG_VCM, "Result info : result type(%d) result text(%s) event(%d) result_message(%s)", + SLOG(LOG_INFO, TAG_VCM, "Result info : result type(%d) result text(%s) event(%d) result_message(%s)", result_type, temp_text, event, temp_message); vc_cmd_print_list(vc_cmd_list); @@ -2046,14 +2046,14 @@ static Eina_Bool __vc_mgr_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCM, "Result : result text(%s) event(%d)", temp_text, event); + SLOG(LOG_INFO, TAG_VCM, "Result : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); vc_mgr_client_use_callback(g_vc_m); callback(event, vc_cmd_list, temp_text, user_data); vc_mgr_client_not_use_callback(g_vc_m); - SLOG(LOG_DEBUG, TAG_VCM, "Result callback called"); + SLOG(LOG_INFO, TAG_VCM, "Result callback called"); vc_cmd_list_destroy(vc_cmd_list, true); diff --git a/client/vc_widget.c b/client/vc_widget.c index fc32ff5..17eb951 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1016,7 +1016,7 @@ static Eina_Bool __vc_widget_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); + SLOG(LOG_INFO, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); @@ -1024,7 +1024,7 @@ static Eina_Bool __vc_widget_notify_result(void *data) callback(event, vc_cmd_list, temp_text, user_data); vc_widget_client_not_use_callback(g_vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "Widget result callback called"); + SLOG(LOG_INFO, TAG_VCW, "Widget result callback called"); /* Release result */ if (NULL != temp_text) free(temp_text); diff --git a/server/vcd_server.c b/server/vcd_server.c index 41f225e..7787e21 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -451,7 +451,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int vc_info_parser_unset_result(vcd_client_manager_get_exclusive()); vcd_client_manager_set_result_text(all_result); - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)", + SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)", event, all_result, non_fixed_result, msg, count); if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) { @@ -508,7 +508,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int int filtered_count = 0; int top_priority = VC_COMMAND_PRIORITY_BACKGROUND; for (i = 0; i < count; i++) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] [%d] Result id(%d)", i, result_id[i]); + SLOG(LOG_INFO, TAG_VCD, "[Server] [%d] Result id(%d)", i, result_id[i]); if (0 > result_id[i]) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Result ID(%d) is NOT valid", result_id[i]); @@ -532,7 +532,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int int is_action = 0; for (i = 0; i < filtered_count; i++) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] [%d] Filtered Result id(%d)", i, filtered_id[i]); + SLOG(LOG_INFO, TAG_VCD, "[Server] [%d] Filtered Result id(%d)", i, filtered_id[i]); if (filtered_id[i] < 0) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Filtered ID(%d) is NOT valid", filtered_id[i]); @@ -572,7 +572,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int } if (NULL != nlu_result) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU (%s)", nlu_result); + SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result); vc_info_parser_set_nlu_result(nlu_result); if (0 == is_action) { vc_cmd_h nlu_cmd; -- 2.7.4 From ecaab19fdc94a53a16d51f40104ce123d4c715b5 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 14 Dec 2016 16:44:28 +0900 Subject: [PATCH 15/16] Fix SVACE issue Change-Id: Ida5604af5260c977a819741581e884da6b539345 Signed-off-by: sooyeon.kim --- common/vc_cmd_db.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 5ed395c..7696982 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1298,7 +1298,9 @@ static int __vc_db_generate_command(vc_cmd_s* cmd, char** fixed_cmd, GSList** cm // remove close brace, '}' char* temp_close = strchr(src_cmd, '}'); - temp_close[0] = '\0'; + if (NULL != temp_close) { + temp_close[0] = '\0'; + } // extract fixed command and remove space in front of '{' char *tok_ptr = NULL; -- 2.7.4 From 33e44a1ec333f64be52c8ae7494ae76311f2a8cf Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 19 Dec 2016 15:34:24 +0900 Subject: [PATCH 16/16] Fix Memory leak / Change log level of 'vcinfo' logs. Change-Id: Ic0bf404adaa3defa609cc0e75f54b758d95e8439 Signed-off-by: Suyeon Hwang --- common/vc_config_mgr.c | 56 +++++++++++++++++++++++------------------------ common/vc_config_parser.c | 39 +++++++++++++++++++-------------- common/vc_info_parser.c | 12 +++++----- common/vc_json_parser.c | 7 +++--- server/vcd_server.c | 3 +++ 5 files changed, 62 insertions(+), 55 deletions(-) diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 822f81d..b82940e 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -145,7 +145,7 @@ int __vc_config_mgr_check_engine_is_valid(const char* engine_id) SLOG(LOG_DEBUG, vc_config_tag(), "Default engine is changed : %s", g_config_info->engine_id); if (0 != vc_parser_set_engine(g_config_info->engine_id)) { - SLOG(LOG_ERROR, vc_config_tag(), " Fail to save config"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config"); return -1; } @@ -233,7 +233,7 @@ int __vc_config_mgr_select_lang(const char* engine_id, char** language) engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, vc_config_tag(), "engine info is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] engine info is NULL"); return false; } @@ -382,13 +382,13 @@ int __vc_config_set_auto_language() /* Check current config info */ if (NULL == g_config_info) { - SLOG(LOG_ERROR, vc_config_tag(), "Current config info is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Current config info is NULL"); return VC_CONFIG_ERROR_OPERATION_FAILED; } /* Check current language */ if (NULL == g_config_info->language) { - SLOG(LOG_ERROR, vc_config_tag(), "Current config language is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Current config language is NULL"); return VC_CONFIG_ERROR_OPERATION_FAILED; } @@ -401,7 +401,7 @@ int __vc_config_set_auto_language() /* vc default language change */ char* before_lang = NULL; if (0 != vc_parser_set_language(candidate_lang)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to save default language"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save default language"); return -1; } @@ -840,7 +840,7 @@ int vc_config_mgr_unset_lang_cb(int uid) int vc_config_mgr_set_enabled_cb(int uid, vc_config_enabled_cb enabled_cb) { if (NULL == enabled_cb) { - SLOG(LOG_ERROR, vc_config_tag(), "enabled cb is NULL : uid(%d) ", uid); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] enabled cb is NULL : uid(%d) ", uid); return VC_CONFIG_ERROR_INVALID_PARAMETER; } @@ -891,7 +891,7 @@ int vc_config_mgr_unset_enabled_cb(int uid) int vc_config_mgr_get_auto_language(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -907,14 +907,14 @@ int vc_config_mgr_get_auto_language(bool* value) int vc_config_mgr_set_auto_language(bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (g_config_info->auto_lang != value) { /* Check language is valid */ if (0 != vc_parser_set_auto_lang(value)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to save engine id"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id"); return -1; } g_config_info->auto_lang = value; @@ -930,12 +930,12 @@ int vc_config_mgr_set_auto_language(bool value) int vc_config_mgr_get_language_list(vc_supported_language_cb callback, void* user_data) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "There is no engine"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] There is no engine"); return -1; } @@ -986,7 +986,7 @@ int vc_config_mgr_get_language_list(vc_supported_language_cb callback, void* use int vc_config_mgr_get_default_language(char** language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -997,7 +997,7 @@ int vc_config_mgr_get_default_language(char** language) if (NULL != g_config_info->language) { *language = strdup(g_config_info->language); } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL"); return -1; } @@ -1007,7 +1007,7 @@ int vc_config_mgr_get_default_language(char** language) int vc_config_mgr_set_default_language(const char* language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1018,13 +1018,13 @@ int vc_config_mgr_set_default_language(const char* language) /* Check language is valid */ if (NULL != g_config_info->language) { if (0 != vc_parser_set_language(language)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to save engine id"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id"); return -1; } free(g_config_info->language); g_config_info->language = strdup(language); } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL"); return -1; } @@ -1034,7 +1034,7 @@ int vc_config_mgr_set_default_language(const char* language) int vc_config_mgr_get_enabled(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1050,12 +1050,12 @@ int vc_config_mgr_get_enabled(bool* value) int vc_config_mgr_set_enabled(bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (0 != vc_parser_set_enabled(value)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to set enabled"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set enabled"); return -1; } @@ -1067,17 +1067,17 @@ int vc_config_mgr_set_enabled(bool value) int vc_config_mgr_get_nonfixed_support(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (NULL == value) { - SLOG(LOG_ERROR, vc_config_tag(), "Input parameter is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL"); return -1; } if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "There is no engine"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] There is no engine"); return -1; } @@ -1111,7 +1111,7 @@ int vc_config_mgr_get_nonfixed_support(bool* value) bool vc_config_check_default_engine_is_valid(const char* engine) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1145,7 +1145,7 @@ bool vc_config_check_default_engine_is_valid(const char* engine) bool vc_config_check_default_language_is_valid(const char* language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1205,7 +1205,7 @@ bool vc_config_check_default_language_is_valid(const char* language) int vc_config_mgr_set_foreground(int pid, bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1215,7 +1215,7 @@ int vc_config_mgr_set_foreground(int pid, bool value) int vc_config_mgr_get_foreground(int* pid) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1269,7 +1269,7 @@ int __vc_config_mgr_print_engine_info() j++; } } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NONE"); + SLOG(LOG_DEBUG, vc_config_tag(), " language is NONE"); } SLOG(LOG_DEBUG, vc_config_tag(), " "); iter = g_slist_next(iter); @@ -1309,4 +1309,4 @@ int __vc_config_mgr_print_client_info() SLOG(LOG_DEBUG, vc_config_tag(), "--------------------------------------------"); return 0; -} +} \ No newline at end of file diff --git a/common/vc_config_parser.c b/common/vc_config_parser.c index f4c3456..92ca095 100644 --- a/common/vc_config_parser.c +++ b/common/vc_config_parser.c @@ -128,7 +128,7 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) temp->name = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_ID); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_ID); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_ENGINE_ID)) { key = xmlNodeGetContent(cur); @@ -138,7 +138,7 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) temp->uuid = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_ID); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_ID); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_ENGINE_LANGUAGE_SET)) { xmlNodePtr lang_node = NULL; @@ -155,7 +155,7 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) temp->languages = g_slist_append(temp->languages, temp_lang); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_LANGUAGE); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_LANGUAGE); } } @@ -171,12 +171,12 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) } else if (0 == xmlStrcmp(key, (const xmlChar *)"false")) { temp->non_fixed_support = false; } else { - SLOG(LOG_ERROR, vc_config_tag(), "Auto voice is wrong"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Auto voice is wrong"); temp->non_fixed_support = false; } xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_NON_FIXED_SUPPORT); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_NON_FIXED_SUPPORT); } } else { @@ -257,7 +257,7 @@ int vc_parser_print_engine_info(vc_engine_info_s* engine_info) i++; } } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NONE"); + SLOG(LOG_DEBUG, vc_config_tag(), " language is NONE"); } SLOG(LOG_DEBUG, vc_config_tag(), "====================="); @@ -343,7 +343,7 @@ int vc_parser_load_config(vc_config_s** config_info) temp->engine_id = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] enable is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] enable is NULL"); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_CONFIG_AUTO_LANGUAGE)) { key = xmlNodeGetContent(cur); @@ -355,13 +355,13 @@ int vc_parser_load_config(vc_config_s** config_info) } else if (0 == xmlStrcmp(key, (const xmlChar *)"off")) { temp->auto_lang = false; } else { - SLOG(LOG_ERROR, vc_config_tag(), "Auto voice is wrong"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Auto voice is wrong"); temp->auto_lang = false; } xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] voice type is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] voice type is NULL"); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_CONFIG_LANGUAGE)) { key = xmlNodeGetContent(cur); @@ -371,7 +371,7 @@ int vc_parser_load_config(vc_config_s** config_info) temp->language = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] language is NULL"); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar*)VC_TAG_CONFIG_ENABLED)) { key = xmlNodeGetContent(cur); @@ -383,11 +383,11 @@ int vc_parser_load_config(vc_config_s** config_info) } else if (0 == xmlStrcmp(key, (const xmlChar *)"off")) { temp->enabled = false; } else { - SLOG(LOG_ERROR, vc_config_tag(), "Enabled service is wrong"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Enabled service is wrong"); temp->enabled = false; } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Enabled service is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Enabled service is NULL"); } } else { @@ -656,7 +656,7 @@ int vc_parser_find_config_changed(int* auto_lang, char** language, int* enabled) xmlFree(key_old); } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Old config and new config are different"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Old config and new config are different"); } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)VC_TAG_CONFIG_LANGUAGE)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)VC_TAG_CONFIG_LANGUAGE)) { @@ -674,7 +674,7 @@ int vc_parser_find_config_changed(int* auto_lang, char** language, int* enabled) xmlFree(key_old); } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] old config and new config are different"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] old config and new config are different"); } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)VC_TAG_CONFIG_ENABLED)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)VC_TAG_CONFIG_ENABLED)) { @@ -695,7 +695,7 @@ int vc_parser_find_config_changed(int* auto_lang, char** language, int* enabled) xmlFree(key_old); } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] old config and new config are different"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] old config and new config are different"); } } else { @@ -716,7 +716,7 @@ int vc_parser_set_foreground(int pid, bool value) int cur_pid = 0; /* Get foreground pid */ if (0 != vc_parser_get_foreground(&cur_pid)) { - SLOG(LOG_DEBUG, vc_config_tag(), "Fail to get pid from info file"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get pid from info file"); return -1; } @@ -759,17 +759,20 @@ int vc_parser_set_foreground(int pid, bool value) cur = xmlDocGetRootElement(doc); if (cur == NULL) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Empty document"); + xmlFreeDoc(doc); return -1; } if (xmlStrcmp(cur->name, (const xmlChar *) VC_TAG_INFO_BASE_TAG)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] The wrong type, root node is NOT %s", VC_TAG_INFO_BASE_TAG); + xmlFreeDoc(doc); return -1; } cur = cur->xmlChildrenNode; if (cur == NULL) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Empty document"); + xmlFreeDoc(doc); return -1; } @@ -792,10 +795,12 @@ int vc_parser_set_foreground(int pid, bool value) int ret = xmlSaveFile(VC_RUNTIME_INFO_FOREGROUND, doc); if (0 >= ret) { - SLOG(LOG_DEBUG, vc_config_tag(), "[ERROR] Fail to save foreground info : %d", ret); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save foreground info : %d", ret); + xmlFreeDoc(doc); return -1; } SLOG(LOG_DEBUG, vc_config_tag(), "[Success] Save foreground info pid(%d)", pid); + xmlFreeDoc(doc); return 0; } diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index c4fc2d4..f46f80a 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -109,7 +109,7 @@ int vc_cmd_parser_delete_file(int pid, vc_cmd_type_e type) if (APP_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] fail to get app id, ret(%d)", ret); } else { - SLOG(LOG_ERROR, vc_info_tag(), "Background cmd: appid = %s", appid); + SLOG(LOG_DEBUG, vc_info_tag(), "Background cmd: appid = %s", appid); } } @@ -379,14 +379,14 @@ int vc_info_parser_get_nlu_result(char** nlu_result) int ret; ret = fscanf(fp, "size(%d)\n", &readn); if (ret <= 0) { - SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Fail to get buffer size"); + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to get buffer size"); fclose(fp); return -1; } SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] buffer size (%d)", readn); if (10000000 < readn || 0 > readn) { - SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Invalid buffer size"); + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Invalid buffer size"); fclose(fp); return -1; } @@ -413,7 +413,7 @@ int vc_info_parser_get_result_pid_list(GSList** pid_list, const char* result) { int ret = vc_db_get_result_pid_list(result, pid_list); if (0 != ret) { - SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Fail to delete result table"); + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to delete result table"); return -1; } return 0; @@ -658,7 +658,7 @@ int __vc_cmd_parser_print_commands(GSList* cmd_list) cmd = iter->data; if (NULL == cmd) { - SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] NULL data from command list"); + SLOG(LOG_WARN, vc_info_tag(), "[WARNING] NULL data from command list"); iter = g_slist_next(iter); continue; } @@ -670,4 +670,4 @@ int __vc_cmd_parser_print_commands(GSList* cmd_list) } return 0; -} +} \ No newline at end of file diff --git a/common/vc_json_parser.c b/common/vc_json_parser.c index 748a607..8ab0e4f 100755 --- a/common/vc_json_parser.c +++ b/common/vc_json_parser.c @@ -206,7 +206,7 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati if (APP_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] fail to get app id, ret(%d)", ret); } else { - SLOG(LOG_ERROR, vc_json_tag(), "Background cmd: appid = %s", appid); + SLOG(LOG_DEBUG, vc_json_tag(), "Background cmd: appid = %s", appid); } } else { appid = strdup(temp_text); @@ -346,7 +346,7 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati } return ret; } - SLOG(LOG_WARN, vc_json_tag(), "[INFO] pid(%d), type(%d), format(%d), domain(%d), cmd(%s), appid(%s)", cmd->pid, type, cmd->format, cmd->domain, cmd->command, cmd->appid); + SLOG(LOG_INFO, vc_json_tag(), "[INFO] pid(%d), type(%d), format(%d), domain(%d), cmd(%s), appid(%s)", cmd->pid, type, cmd->format, cmd->domain, cmd->command, cmd->appid); if (NULL != cmd->appid) { free(cmd->appid); @@ -469,5 +469,4 @@ int vc_json_set_all_commands_from_file(const char* file_path) g_object_unref(parser); return ret; -} - +} \ No newline at end of file diff --git a/server/vcd_server.c b/server/vcd_server.c index 7787e21..112e13b 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -242,18 +242,21 @@ static int __vcd_activate_app_by_appcontrol(const char* appid) ret = app_control_add_extra_data(app_control, "voice_launch", "get_result"); if (APP_CONTROL_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to add extra data, ret(%d)", ret); + app_control_destroy(app_control); return VCD_ERROR_OPERATION_FAILED; } // Set an app ID. ret = app_control_set_app_id(app_control, appid); if (APP_CONTROL_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set app id, ret(%d)", ret); + app_control_destroy(app_control); return VCD_ERROR_OPERATION_FAILED; } // Sent launch request ret = app_control_send_launch_request(app_control, NULL, NULL); if (APP_CONTROL_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send launch request, ret(%d)", ret); + app_control_destroy(app_control); return VCD_ERROR_OPERATION_FAILED; } // Destroy app control -- 2.7.4