Add priority for Widget command 61/166161/4
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 8 Jan 2018 09:28:04 +0000 (18:28 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 9 Jan 2018 01:03:06 +0000 (10:03 +0900)
Change-Id: I6b2e21db43366c7b821524f79c7869fc5d133e51
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
common/vc_cmd_db.c
common/vc_command.h
server/vcd_client_data.c
server/vcd_server.c

index 5b1face..d55a171 100644 (file)
@@ -1200,8 +1200,8 @@ static vc_cmd_s* __vc_db_command_copy(vc_cmd_s* src_cmd)
 
        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_WIDGET == temp_cmd->type)      temp_cmd->priority = VC_COMMAND_PRIORITY_WIDGET;
        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;
 
index b4eadab..b772774 100644 (file)
@@ -77,9 +77,10 @@ typedef enum {
 typedef enum {
        VC_COMMAND_PRIORITY_SYSTEM = 1,
        VC_COMMAND_PRIORITY_EXCLUSIVE = 2,
-       VC_COMMAND_PRIORITY_FOREGROUND = 3,
-       VC_COMMAND_PRIORITY_SYSTEM_BACKGROUND = 4,
-       VC_COMMAND_PRIORITY_BACKGROUND = 5
+       VC_COMMAND_PRIORITY_WIDGET = 3,
+       VC_COMMAND_PRIORITY_FOREGROUND = 4,
+       VC_COMMAND_PRIORITY_SYSTEM_BACKGROUND = 5,
+       VC_COMMAND_PRIORITY_BACKGROUND = 6
 } vc_cmd_priority_e;
 
 int vc_cmd_set_id(vc_cmd_h vc_command, int id);
index ff3e686..bbf0fa5 100644 (file)
@@ -580,8 +580,8 @@ static vc_cmd_s* __command_copy(vc_cmd_s* src_cmd)
 
        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_WIDGET == temp_cmd->type)      temp_cmd->priority = VC_COMMAND_PRIORITY_WIDGET;
        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;
 
index 2908e9f..9897853 100755 (executable)
@@ -466,7 +466,7 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c
        vc_info_parser_unset_result(vcd_client_manager_get_exclusive());
        vcd_client_manager_set_result_text(all_result);
 
-       SLOG(LOG_INFO, 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()) {
@@ -502,48 +502,6 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c
                }
        }
 #if 1
-
-       int pid = vcd_client_widget_get_foreground_pid();
-       if (-1 != pid) {
-               if (NULL != all_result) {
-                       bool enable = false;
-                       vcd_client_widget_get_asr_result_enabled(pid, &enable);
-                       if (true == enable) {
-                               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client");
-                               bool is_consumed = false;
-                               if (NULL != user_info) {
-                                       *user_info = 0x00;
-                               }
-                               if (0 != vcdc_send_asr_result(pid, event, all_result, VC_COMMAND_TYPE_WIDGET, &is_consumed)) {
-                                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result");
-                               } else {
-                                       SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed);
-                                       if (true == is_consumed) {
-                                               if (NULL != user_info) {
-                                                       *user_info = 0x01;
-                                                       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send whether ASR result is consumed or not (%d)", *user_info);
-                                               }
-                                               vcdc_send_show_tooltip(pid, false);
-                                               if (-1 != vcd_client_manager_get_pid()) {
-                                                       /* Manager client is available */
-                                                       vc_info_parser_unset_result(false);
-                                                       vc_info_parser_set_result(all_result, VC_RESULT_EVENT_RESULT_SUCCESS, msg, NULL, false);
-                                                       if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
-                                                               SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
-                                                       }
-                                               }
-
-                                               vcd_client_manager_set_exclusive(false);
-
-                                               vcd_config_set_service_state(VCD_STATE_READY);
-                                               vcdc_send_service_state(VCD_STATE_READY);
-                                               return VCD_ERROR_NONE;
-                                       }
-                               }
-                       }
-               }
-       }
-
        /* if nlu_result is exist, Add command handle(is_action) into result list */
        /* Normal result */
        SLOG(LOG_DEBUG, TAG_VCD, "[Server] @ Get engine result @");
@@ -560,7 +518,7 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c
        }
 
        /* priority filter */
-       /* system > exclusive > foreground = widget > system_background > background */
+       /* system > exclusive > widget > foreground > system_background > background */
        int i = 0;
        int* filtered_id = (int*)calloc(count, sizeof(int));
        if (!filtered_id) {
@@ -593,6 +551,56 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c
                }
        }
 
+       // ASR consume
+       if (top_priority >= VC_COMMAND_PRIORITY_WIDGET) {
+               int pid = vcd_client_widget_get_foreground_pid();
+               if (-1 != pid) {
+                       if (NULL != all_result) {
+                               vc_info_parser_set_result(all_result, event, msg, NULL, false);
+                               bool enable = false;
+                               vcd_client_widget_get_asr_result_enabled(pid, &enable);
+                               if (true == enable) {
+                                       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client");
+                                       bool is_consumed = false;
+                                       if (NULL != user_info) {
+                                               *user_info = 0x00;
+                                       }
+                                       if (0 != vcdc_send_asr_result(pid, event, all_result, VC_COMMAND_TYPE_WIDGET, &is_consumed)) {
+                                               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result");
+                                       } else {
+                                               SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed);
+                                               if (true == is_consumed) {
+                                                       if (NULL != user_info) {
+                                                               *user_info = 0x01;
+                                                               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send whether ASR result is consumed or not (%d)", *user_info);
+                                                       }
+                                                       vcdc_send_show_tooltip(pid, false);
+                                                       if (-1 != vcd_client_manager_get_pid()) {
+                                                               /* Manager client is available */
+                                                               vc_info_parser_unset_result(false);
+                                                               vc_info_parser_set_result(all_result, VC_RESULT_EVENT_RESULT_SUCCESS, msg, NULL, false);
+                                                               if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+                                                                       SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
+                                                               }
+                                                       }
+
+                                                       vcd_client_manager_set_exclusive(false);
+
+                                                       vcd_config_set_service_state(VCD_STATE_READY);
+                                                       vcdc_send_service_state(VCD_STATE_READY);
+                                                       vc_cmd_list_destroy(vc_cmd_list, true);
+                                                       if (NULL != filtered_id) {
+                                                               free(filtered_id);
+                                                               filtered_id = NULL;
+                                                       }
+                                                       return VCD_ERROR_NONE;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
        int is_action = 0;
        for (i = 0; i < filtered_count; i++) {
                SLOG(LOG_INFO, TAG_VCD, "[Server]   [%d] Filtered Result id(%d)", i, filtered_id[i]);