}
/* priority filter */
- /* system > exclusive > widget > foreground > system_background > background */
+ /* system > exclusive > widget > foreground > system_background > widget partial > foreground paritial > background */
int i = 0;
int* filtered_id = (int*)calloc(count, sizeof(int));
if (!filtered_id) {
/* Handle the result list */
if (0 == result_count) {
/* No result */
+ vc_cmd_list_h widget_cmd_list = NULL;
+ vc_cmd_list_h foreground_cmd_list = NULL;
if (NULL != all_result) {
- vc_cmd_list_h fg_priority_cmd_list = NULL;
SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result);
+ int cnt = 0;
- if (0 != vc_cmd_list_create(&fg_priority_cmd_list)) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create command list handle");
+ if (0 != vc_cmd_list_create(&widget_cmd_list)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create widget command list handle");
vc_cmd_list_destroy(vc_cmd_list, true);
return VCD_ERROR_OUT_OF_MEMORY;
}
- /* Get the list of foreground and widget type commands */
- vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_FOREGROUND, fg_priority_cmd_list);
- vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_WIDGET, fg_priority_cmd_list);
-
- /* Matching algorithm */
- vc_cmd_get_partially_matched_cmd_list(all_result, fg_priority_cmd_list, vc_cmd_list, VC_SEARCH_CHAR_LEVEL);
+ /* Get the list of widget type commands */
+ vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_WIDGET, widget_cmd_list);
+ vc_cmd_list_get_count(widget_cmd_list, &cnt);
+ if (0 < cnt) {
+ /* Matched with widget command partially */
+ vc_cmd_get_partially_matched_cmd_list(all_result, widget_cmd_list, vc_cmd_list, VC_SEARCH_CHAR_LEVEL);
+ vc_cmd_list_get_count(vc_cmd_list, &cnt);
+ if (0 < cnt) {
+ top_priority = VC_COMMAND_PRIORITY_WIDGET;
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Partially matched widget command");
+ }
+ } else {
+ if (0 != vc_cmd_list_create(&foreground_cmd_list)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create foreground command list handle");
+ vc_cmd_list_destroy(vc_cmd_list, true);
+ vc_cmd_list_destroy(widget_cmd_list, true);
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
- vc_cmd_list_destroy(fg_priority_cmd_list, true);
+ /* Get the list of foreground type commands */
+ vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_FOREGROUND, foreground_cmd_list);
+ vc_cmd_list_get_count(foreground_cmd_list, &cnt);
+ if (0 < cnt) {
+ /* Matched with foreground command partially */
+ vc_cmd_get_partially_matched_cmd_list(all_result, foreground_cmd_list, vc_cmd_list, VC_SEARCH_CHAR_LEVEL);
+ vc_cmd_list_get_count(vc_cmd_list, &cnt);
+ if (0 < cnt) {
+ top_priority = VC_COMMAND_PRIORITY_FOREGROUND;
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Partially matched foreground command");
+ }
+ }
+ vc_cmd_list_destroy(foreground_cmd_list, true);
+ }
+ vc_cmd_list_destroy(widget_cmd_list, true);
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is NULL");
}
// After running partial matching algorithm, if there is no result.
if (0 == result_count) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] No commands even after partial matching");
+
bool temp = vcd_client_manager_get_exclusive();
vc_info_parser_set_result(all_result, event, msg, NULL, temp);
}
// Partial matching algorithm find some commands
- top_priority = VC_COMMAND_PRIORITY_FOREGROUND;
event = VC_RESULT_EVENT_RESULT_SUCCESS;
}
if (false == vcd_client_manager_get_exclusive()) {
/* Foreground, Widget, Background, System, System-Background */
if (top_priority >= VC_COMMAND_PRIORITY_BACKGROUND) {
- vc_cmd_list_h fg_priority_cmd_list = NULL;
+ vc_cmd_list_h widget_cmd_list = NULL;
+ vc_cmd_list_h foreground_cmd_list = NULL;
vc_cmd_list_h temp_list = NULL;
+ int cnt = 0;
- if (0 != vc_cmd_list_create(&fg_priority_cmd_list)) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create command list handle");
+ if (0 != vc_cmd_list_create(&temp_list)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create widget command list handle");
vc_cmd_list_destroy(vc_cmd_list, true);
return VCD_ERROR_OUT_OF_MEMORY;
}
- if (0 != vc_cmd_list_create(&temp_list)) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create command list handle");
- vc_cmd_list_destroy(fg_priority_cmd_list, true);
+ if (0 != vc_cmd_list_create(&widget_cmd_list)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create widget command list handle");
vc_cmd_list_destroy(vc_cmd_list, true);
+ vc_cmd_list_destroy(temp_list, true);
return VCD_ERROR_OUT_OF_MEMORY;
}
- /* Get the list of foreground and widget type commands */
- vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_FOREGROUND, fg_priority_cmd_list);
- vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_WIDGET, fg_priority_cmd_list);
-
- /* Matching algorithm */
- vc_cmd_get_partially_matched_cmd_list(all_result, fg_priority_cmd_list, temp_list, VC_SEARCH_CHAR_LEVEL);
- vc_cmd_list_destroy(fg_priority_cmd_list, true);
-
- vc_cmd_list_get_count(temp_list, &result_count);
+ /* Get the list of widget type commands */
+ vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_WIDGET, widget_cmd_list);
+ vc_cmd_list_get_count(widget_cmd_list, &cnt);
+ if (0 < cnt) {
+ /* Matched with widget command partially */
+ vc_cmd_get_partially_matched_cmd_list(all_result, widget_cmd_list, temp_list, VC_SEARCH_CHAR_LEVEL);
+ vc_cmd_list_get_count(temp_list, &cnt);
+ if (0 < cnt) {
+ if (0 != vc_cmd_list_destroy(vc_cmd_list, true)) {
+ SLOG(LOG_WARN, TAG_VCD, "[WARNING] Fail to destroy list");
+ }
+ vc_cmd_list = temp_list;
+ top_priority = VC_COMMAND_PRIORITY_WIDGET;
+ event = VC_RESULT_EVENT_RESULT_SUCCESS;
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Partially matched widget command when background cmd exists");
+ }
+ } else {
+ if (0 != vc_cmd_list_create(&foreground_cmd_list)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create foreground command list handle");
+ vc_cmd_list_destroy(vc_cmd_list, true);
+ vc_cmd_list_destroy(widget_cmd_list, true);
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
- if (0 < result_count) {
- if (0 != vc_cmd_list_destroy(vc_cmd_list, true)) {
- SLOG(LOG_WARN, TAG_VCD, "[WARNING] Fail to destroy list");
+ /* Get the list of foreground type commands */
+ vcd_client_append_cmd_from_type(VC_COMMAND_TYPE_FOREGROUND, foreground_cmd_list);
+ vc_cmd_list_get_count(foreground_cmd_list, &cnt);
+ if (0 < cnt) {
+ /* Matched with foreground command partially */
+ vc_cmd_get_partially_matched_cmd_list(all_result, foreground_cmd_list, temp_list, VC_SEARCH_CHAR_LEVEL);
+ vc_cmd_list_get_count(temp_list, &cnt);
+ if (0 < cnt) {
+ if (0 != vc_cmd_list_destroy(vc_cmd_list, true)) {
+ SLOG(LOG_WARN, TAG_VCD, "[WARNING] Fail to destroy list");
+ }
+ vc_cmd_list = temp_list;
+ top_priority = VC_COMMAND_PRIORITY_FOREGROUND;
+ event = VC_RESULT_EVENT_RESULT_SUCCESS;
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Partially matched foreground command when background cmd exists");
+ }
}
- vc_cmd_list = temp_list;
- event = VC_RESULT_EVENT_RESULT_SUCCESS;
+ vc_cmd_list_destroy(foreground_cmd_list, true);
}
+ vc_cmd_list_destroy(widget_cmd_list, true);
+ vc_cmd_list_destroy(temp_list, true);
}
int pid = vcd_client_widget_get_foreground_pid();