Update dialog and api 26/89726/3 accepted/tizen/common/20160926.155400 accepted/tizen/ivi/20160927.021844 accepted/tizen/mobile/20160927.021935 accepted/tizen/tv/20160927.021754 accepted/tizen/wearable/20160927.021946 submit/tizen/20160926.132531
authorWonnam Jang <wn.jang@samsung.com>
Mon, 26 Sep 2016 12:36:15 +0000 (21:36 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Mon, 26 Sep 2016 13:07:47 +0000 (22:07 +0900)
Change-Id: Iae4c6190c631a78e5ea75aaa8c3d546155b99476
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
client/vc.c
client/vc_mgr.c
common/vc_cmd_db.c
common/vc_cmd_db.h
common/vc_json_parser.c
include/voice_control.h
include/voice_control_command.h
include/voice_control_command_expand.h
server/vcd_client_data.c
server/vcd_client_data.h
server/vcd_server.c

index 327db61f333f7298421b1fe790fc008a2e4b29d5..e6b4de91f3a3750e8ad6f62305791158505d2f00 100644 (file)
@@ -2035,7 +2035,7 @@ int vc_set_invocation_name(const char* name)
        return ret;
 }
 
-int vc_dialog(const char* disp_text, const char* utt_text, bool continuous)
+int vc_dialog(const char* disp_text, const char* utt_text, bool auto_start)
 {
        vc_state_e state;
 
@@ -2072,8 +2072,8 @@ int vc_dialog(const char* disp_text, const char* utt_text, bool continuous)
                return VC_ERROR_INVALID_STATE;
        }
 
-       SLOG(LOG_DEBUG, TAG_VCC, "Request dialog : pid(%d) disp_text(%s), utt_text(%s), continuous(%d)", getpid(), disp_text, utt_text, continuous);
-       int ret = vc_dbus_request_dialog(getpid(), disp_text, utt_text, continuous);
+       SLOG(LOG_DEBUG, TAG_VCC, "Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start);
+       int ret = vc_dbus_request_dialog(getpid(), disp_text, utt_text, auto_start);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret);
                return VC_ERROR_OPERATION_FAILED;
index f7aed9886503aac6987006c54a01308813f1f993..603e1129d6a6905d4fc1775fb382d62930e5df52 100644 (file)
@@ -2508,7 +2508,7 @@ int __vc_mgr_cb_dialog(int pid, const char* disp_text, const char* utt_text, boo
                vc_mgr_client_use_callback(g_vc_m);
                callback(pid, disp_text, utt_text, continuous, user_data);
                vc_mgr_client_not_use_callback(g_vc_m);
-               SLOG(LOG_DEBUG, TAG_VCM, "Error callback is called");
+               SLOG(LOG_DEBUG, TAG_VCM, "Dialog callback is called");
        } else {
                SLOG(LOG_WARN, TAG_VCM, "[WARNING] Error callback is null");
        }
index 3b627df89acdb45382119c2be04db7a5279be850..01681299f6ce94e64dee0254e5d3b9516a06082d 100644 (file)
@@ -1167,6 +1167,24 @@ int vc_db_delete_table(const char* table)
        return VC_DB_ERROR_NONE;
 }
 
+int vc_db_begin_transaction(void)
+{
+       int ret = __vc_db_begin_transaction();
+       return ret;
+}
+
+int vc_db_rollback_transaction(void)
+{
+       int ret = __vc_db_rollback_transaction();
+       return ret;
+}
+
+int vc_db_commit_transaction(void)
+{
+       int ret = __vc_db_commit_transaction();
+       return ret;
+}
+
 static void __vc_db_remove_space(char** string)
 {
        if (NULL == string || NULL == *string)
@@ -1310,8 +1328,6 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd)
                return ret;
        }
 
-       __vc_db_begin_transaction();
-
        if (0 != g_slist_length(cmd_list)) {
                GSList *iter = NULL;
                char* temp_command = NULL;
@@ -1333,7 +1349,6 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd)
 
                                int ret = __vc_db_insert_commands(pid, type, cmd);
                                if (ret != VC_DB_ERROR_NONE) {
-                                       __vc_db_rollback_transaction();
                                        if (NULL != fixed_cmd) {
                                                free(fixed_cmd);
                                                fixed_cmd = NULL;
@@ -1351,7 +1366,6 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd)
 
                                        ret = __vc_db_insert_commands(pid, type, cmd);
                                        if (ret != VC_DB_ERROR_NONE) {
-                                               __vc_db_rollback_transaction();
                                                if (NULL != fixed_cmd) {
                                                        free(fixed_cmd);
                                                        fixed_cmd = NULL;
@@ -1370,8 +1384,6 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd)
                cmd_list = NULL;
        }
 
-       __vc_db_commit_transaction();
-
        if (NULL != fixed_cmd) {
                free(fixed_cmd);
                fixed_cmd = NULL;
@@ -1390,6 +1402,8 @@ int vc_db_insert_commands_list(int pid, vc_cmd_type_e type, GSList* cmd_list, ch
 
        SLOG(LOG_DEBUG, vc_db_tag(), "list count : %d", count);
 
+       __vc_db_begin_transaction();
+
        for (i = 0; i < count; i++) {
                if (NULL == iter)
                        break;
@@ -1408,6 +1422,7 @@ int vc_db_insert_commands_list(int pid, vc_cmd_type_e type, GSList* cmd_list, ch
                        int ret = vc_db_insert_command(pid, type, temp_cmd);
                        if (ret != VC_DB_ERROR_NONE) {
                                SLOG(LOG_ERROR, vc_db_tag(), "Fail to insert command, ret(%d)", ret);
+                               __vc_db_rollback_transaction();
                                return ret;
                        }
                } else {
@@ -1416,6 +1431,8 @@ int vc_db_insert_commands_list(int pid, vc_cmd_type_e type, GSList* cmd_list, ch
                iter = g_slist_next(iter);
        }
 
+       __vc_db_commit_transaction();
+
        return VC_DB_ERROR_NONE;
 }
 
index c8133e7563a3d4c35348c1860f1c29c4e2eaa452..c0028b6c0b451b48e422eaeeae16e1838de330d8 100644 (file)
@@ -55,6 +55,12 @@ int vc_db_create_table(void);
 
 int vc_db_delete_table(const char* table);
 
+int vc_db_begin_transaction(void);
+
+int vc_db_rollback_transaction(void);
+
+int vc_db_commit_transaction(void);
+
 int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd);
 
 int vc_db_insert_commands_list(int pid, vc_cmd_type_e type, GSList* cmd_list, char* invocation_name);
index f49d6d6c4063071650b8ec0a07aab43d37f7932c..6d50d5113d4a3c630cce6c39c398b81caf0890ed 100644 (file)
@@ -128,6 +128,12 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
                }
        }
 
+       ret = vc_db_begin_transaction();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+               return ret;
+       }
+
        for (i = 0; i < array_size; i++) {
                int temp = 0;
                const char* temp_text = NULL;
@@ -139,6 +145,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
                        free(prev_appid);
                        temp_type = NULL;
                        prev_appid = NULL;
+                       ret = vc_db_rollback_transaction();
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                               return ret;
+                       }
                        return VC_ERROR_OUT_OF_MEMORY;
                }
 
@@ -152,6 +163,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
                        temp_type = NULL;
                        prev_appid = NULL;
                        cmd = NULL;
+                       ret = vc_db_rollback_transaction();
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                               return ret;
+                       }
                        return VC_ERROR_OPERATION_FAILED;
                }
 
@@ -173,6 +189,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
                        temp_type = NULL;
                        prev_appid = NULL;
                        cmd = NULL;
+                       ret = vc_db_rollback_transaction();
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                               return ret;
+                       }
                        return VC_ERROR_OUT_OF_MEMORY;
                }
 
@@ -206,7 +227,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
                                        prev_appid = NULL;
                                        free(cmd);
                                        cmd = NULL;
-
+                                       ret = vc_db_rollback_transaction();
+                                       if (0 != ret) {
+                                               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                                               return ret;
+                                       }
                                        return VC_ERROR_OUT_OF_MEMORY;
                                }
                        } else {
@@ -239,6 +264,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
 
                                free(cmd);
                                cmd = NULL;
+                               ret = vc_db_rollback_transaction();
+                               if (0 != ret) {
+                                       SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                                       return ret;
+                               }
                                return VC_ERROR_OUT_OF_MEMORY;
                        }
 
@@ -260,6 +290,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
 
                                        free(cmd);
                                        cmd = NULL;
+                                       ret = vc_db_rollback_transaction();
+                                       if (0 != ret) {
+                                               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                                               return ret;
+                                       }
                                        return ret;
                                }
 
@@ -279,7 +314,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
 
                                        free(cmd);
                                        cmd = NULL;
-
+                                       ret = vc_db_rollback_transaction();
+                                       if (0 != ret) {
+                                               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                                               return ret;
+                                       }
                                        return VC_ERROR_OUT_OF_MEMORY;
                                }
                        }
@@ -300,6 +339,11 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
                        prev_appid = NULL;
                        free(cmd);
                        cmd = NULL;
+                       ret = vc_db_rollback_transaction();
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to begin transaction for db");
+                               return ret;
+                       }
                        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);
@@ -319,6 +363,12 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati
                cmd = NULL;
        }
 
+       ret = vc_db_commit_transaction();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] Fail to commit transaction for db");
+               return ret;
+       }
+
        free(temp_type);
        free(prev_appid);
        temp_type = NULL;
index ef6cf500b04633040cf39cd5a69558f29498a1fb..205a39ad882951945dbad0bd608411a09498f59f 100644 (file)
@@ -312,7 +312,7 @@ int vc_set_invocation_name(const char* name);
 *
 * @pre The service state should be #VC_SERVICE_STATE_READY.
 */
-int vc_dialog(const char* disp_text, const char* utt_text, bool continuous);
+int vc_dialog(const char* disp_text, const char* utt_text, bool auto_start);
 
 /**
 * @brief Sets command list.
index 188675d95d70bd02a9ea6f02c75dcb220b829dcc..f913caad91d0778744dc05eb8f80405369b4c710 100644 (file)
@@ -459,20 +459,6 @@ int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format);
 */
 int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format);
 
-/**
-* @brief Gets nlu json data.
-* @since_tizen 3.0
-*
-* @param[in] vc_command The command handle
-* @param[out] json The nlu json data
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VC_ERROR_NONE Successful
-* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VC_ERROR_NOT_SUPPORTED Not supported feature
-*
-*/
-int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json);
 
 #ifdef __cplusplus
 }
index 1e9b1b129b28104074aa9434e3174a853064e46a..8bd196c67ffd8657d98dd9b608093769049b26a0 100644 (file)
@@ -183,6 +183,22 @@ int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid);
 */
 int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command);
 
+/**
+* @brief Gets nlu json data.
+* @since_tizen 3.0
+*
+* @param[in] vc_command The command handle
+* @param[out] json The nlu json data
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VC_ERROR_NOT_SUPPORTED Not supported feature
+*
+*/
+int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json);
+
+
 #ifdef __cplusplus
 }
 #endif
index d307a13fd524d00e98a818cf92f31673c4eb5d76..70f3749b6a62a838e6a03b7b130be14e0646282f 100644 (file)
@@ -14,8 +14,9 @@
 * limitations under the License.
 */
 
-
+#include <app_manager.h>
 #include <aul.h>
+
 #include "vcd_client_data.h"
 #include "vcd_config.h"
 #include "vcd_main.h"
@@ -46,14 +47,26 @@ vc_client_info_s* __client_get_element(int pid);
 
 int vcd_client_manager_set(int pid)
 {
-       if (-1 != g_manager.pid) {
+       if (-1 != g_manager.pid && NULL != g_manager.appid) {
                SLOG(LOG_DEBUG, TAG_VCD, "Manager has already registered");
                return -1;
        }
        g_manager.pid = pid;
        g_manager.manager_cmd = false;
        g_manager.exclusive_cmd_option = false;
+       g_manager.appid = NULL;
+
+       // Get appid by pid using app control
+       char* appid = NULL;
+       int ret = app_manager_get_app_id(pid, &appid);
+       if (0 != ret || NULL == appid) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] fail to get app id, ret(%d), pid(%d)", ret, pid);
+               return -1;
+       }
+       g_manager.appid = strdup(appid);
 
+       free(appid);
+       appid = NULL;
        return 0;
 }
 
@@ -66,6 +79,15 @@ int vcd_client_manager_unset()
        return 0;
 }
 
+int vcd_client_manager_unset_appid()
+{
+       if (NULL != g_manager.appid) {
+               free(g_manager.appid);
+               g_manager.appid = NULL;
+       }
+       return 0;
+}
+
 bool vcd_client_manager_is_valid(int pid)
 {
        if (-1 == g_manager.pid || pid == g_manager.pid) {
@@ -197,6 +219,14 @@ int vcd_client_manager_get_pid()
        return g_manager.pid;
 }
 
+int vcd_client_manager_get_appid(char** appid)
+{
+       if (NULL != g_manager.appid)
+               *appid = strdup(g_manager.appid);
+
+       return 0;
+}
+
 int vcd_client_manager_set_result_text(const char* result)
 {
        if (NULL != g_result_text) {
index 6985a1f4dfffdbe1d6795297f679385937230f95..62f31206af57312ff1734712d2b8f2e1949890e1 100644 (file)
@@ -54,6 +54,7 @@ typedef struct {
 
 typedef struct {
        int     pid;
+       char*   appid;
        bool    manager_cmd;
        bool    exclusive_cmd_option;
 } manager_info_s;
@@ -101,6 +102,8 @@ int vcd_client_manager_set(int pid);
 
 int vcd_client_manager_unset();
 
+int vcd_client_manager_unset_appid();
+
 bool vcd_client_manager_is_valid(int pid);
 
 int vcd_client_manager_set_command(int pid);
@@ -117,6 +120,8 @@ int vcd_client_manager_set_exclusive(bool value);
 
 int vcd_client_manager_get_pid();
 
+int vcd_client_manager_get_appid(char** appid);
+
 int vcd_client_manager_set_result_text(const char* result);
 
 char* vcd_client_manager_get_result_text();
index 95b81f17176c2b89de1b322474d12ac1d8297251..843b58750737fac22ca72b8c0ea7ddfeb94c4a6a 100644 (file)
@@ -1036,6 +1036,8 @@ void vcd_finalize()
                SLOG(LOG_DEBUG, TAG_VCD, "[Server] release engine");
        }
 
+       vcd_client_manager_unset_appid();
+
        vcd_config_set_service_state(VCD_STATE_NONE);
        vcdc_send_service_state(VCD_STATE_NONE);
 
@@ -1854,6 +1856,55 @@ int vcd_server_set_foreground(int pid, bool value)
        return 0;
 }
 
+static int __vcd_server_launch_manager_app()
+{
+       int ret = -1;
+       bool running = false;
+       char* appid = NULL;
+
+       ret = vcd_client_manager_get_appid(&appid);
+       if (0 != ret || NULL == appid) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get manager appid");
+               return VCD_ERROR_OPERATION_FAILED;
+       }
+       ret = app_manager_is_running(appid, &running);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to check running with appid(%s)", appid);
+               free(appid);
+               appid = NULL;
+               return VCD_ERROR_OPERATION_FAILED;
+       }
+       if (false == running) {
+               int tmp_ret = __vcd_is_package_installed(appid);
+               if (false == tmp_ret) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] manager app is not installed, appid(%s)", appid);
+               } else {
+                       ret = __vcd_activate_app_by_appcontrol(appid);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to activate app");
+                               free(appid);
+                               appid = NULL;
+                               return ret;
+                       }
+                       SLOG(LOG_ERROR, TAG_VCD, "Launch vc manager app: appid(%s)", appid);
+               }
+       } else {
+               ret = __vcd_resume_app(appid);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to resume app");
+                       free(appid);
+                       appid = NULL;
+                       return ret;
+               }
+               SLOG(LOG_ERROR, TAG_VCD, "Resume vc manager app: appid(%s)", appid);
+       }
+
+       free(appid);
+       appid = NULL;
+
+       return VCD_ERROR_NONE;
+}
+
 int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int continuous)
 {
        /* check if pid is valid */
@@ -1862,9 +1913,16 @@ int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int
                return VCD_ERROR_INVALID_PARAMETER;
        }
 
-       if (0 != vcdc_send_dialog(vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous)) {
+       int ret = __vcd_server_launch_manager_app();
+       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 VCD_ERROR_OPERATION_FAILED;
+               return ret;
+       }
+
+       ret = vcdc_send_dialog(vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous);
+       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;
        }
 
        return 0;