From 6304a412ac3bd88bb362dab4bfecee0e8f9ed84a Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 12 Apr 2017 10:51:23 +0900 Subject: [PATCH] Fix calling duplicated result callback Change-Id: I3c1b2a49bb2aa1d0e795c1811a4d1ccee83cc12b Signed-off-by: Suyeon Hwang --- common/vc_cmd_db.c | 8 +++----- server/vcd_server.c | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 4218894..30e0266 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -989,7 +989,8 @@ int __vc_db_get_result_pid_list(const char* result, GSList** pid_list) int ret = 0; sqlite3_stmt* stmt = NULL; - const char* sql = "SELECT * FROM vc_result WHERE result = ? COLLATE NOCASE;"; + const char* sql = "SELECT DISTINCT pid, type FROM vc_result WHERE result = ? COLLATE NOCASE ORDER BY pid ASC;"; + ret = sqlite3_prepare_v2(db_handle, sql, -1, &stmt, NULL); if (ret != SQLITE_OK) { @@ -1031,12 +1032,9 @@ int __vc_db_get_result_pid_list(const char* result, GSList** pid_list) } temp = sqlite3_column_int(stmt, 0); - temp_cmd->id = temp; - - temp = sqlite3_column_int(stmt, 5); temp_cmd->pid = temp; - temp = sqlite3_column_int(stmt, 6); + temp = sqlite3_column_int(stmt, 1); temp_cmd->type = temp; temp_pid_list = g_slist_append(temp_pid_list, temp_cmd); diff --git a/server/vcd_server.c b/server/vcd_server.c index de53304..26f4b7c 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -387,12 +387,14 @@ static Eina_Bool __vcd_send_selected_result(void *data) GSList* iter = NULL; vc_cmd_s* temp_cmd = NULL; int ret = 0; + int pre_pid = -1; + int pre_type = -1; iter = g_slist_nth(pid_list, 0); while (NULL != iter) { temp_cmd = iter->data; - if (NULL != temp_cmd) { + if (NULL != temp_cmd && (pre_pid != temp_cmd->pid || pre_type == VC_COMMAND_TYPE_WIDGET || temp_cmd->type == VC_COMMAND_TYPE_WIDGET)) { /* Launch deactivated several apps that is matched with result */ ret = __vcd_launch_app(result); if (0 != ret) { @@ -405,6 +407,8 @@ static Eina_Bool __vcd_send_selected_result(void *data) break; } else { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type); + pre_pid = temp_cmd->pid; + pre_type = temp_cmd->type; } } free(temp_cmd); -- 2.7.4