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;
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;
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");
}
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)
return ret;
}
- __vc_db_begin_transaction();
-
if (0 != g_slist_length(cmd_list)) {
GSList *iter = NULL;
char* temp_command = NULL;
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;
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;
cmd_list = NULL;
}
- __vc_db_commit_transaction();
-
if (NULL != fixed_cmd) {
free(fixed_cmd);
fixed_cmd = NULL;
SLOG(LOG_DEBUG, vc_db_tag(), "list count : %d", count);
+ __vc_db_begin_transaction();
+
for (i = 0; i < count; i++) {
if (NULL == iter)
break;
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 {
iter = g_slist_next(iter);
}
+ __vc_db_commit_transaction();
+
return VC_DB_ERROR_NONE;
}
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);
}
}
+ 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;
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;
}
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;
}
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;
}
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 {
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;
}
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;
}
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;
}
}
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);
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;
*
* @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.
*/
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
}
*/
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
* limitations under the License.
*/
-
+#include <app_manager.h>
#include <aul.h>
+
#include "vcd_client_data.h"
#include "vcd_config.h"
#include "vcd_main.h"
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;
}
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) {
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) {
typedef struct {
int pid;
+ char* appid;
bool manager_cmd;
bool exclusive_cmd_option;
} manager_info_s;
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);
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();
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);
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 */
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;