return 0;
}
+int __vc_cb_error_to_app(int pid, int reason, const char* msg)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] send error to app(%d)", pid);
+
+ vc_h vc;
+ if (0 != vc_client_get_handle(pid, &vc)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get vc handle");
+ return VC_ERROR_INVALID_PARAMETER;
+ }
+
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Error reason(%d), msg(%s)", reason, msg);
+
+ vc_client_set_error(vc, reason);
+ ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)vc);
+
+ return VC_ERROR_NONE;
+}
+
static void __vc_notify_state_changed(void *data)
{
vc_h vc = (vc_h)data;
client->is_foreground = false;
client->invocation_name = NULL;
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. uid(%u)", client->uid);
+
g_client_list = g_slist_append(g_client_list, client);
*vc = temp;
}
//LCOV_EXCL_START
-int vc_client_get_handle(unsigned int uid, vc_h* vc)
+int vc_client_get_handle(int pid, vc_h* vc)
{
vc_client_s *data = NULL;
int count = g_slist_length(g_client_list);
int i;
+ SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The number of VC clients(%d)", count);
+
for (i = 0; i < count; i++) {
data = g_slist_nth_data(g_client_list, i);
if (NULL != data) {
- if (uid == data->vc->handle) {
+ SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] pid(%d), handle(%d)", pid, data->vc->handle);
+ if (pid == data->vc->handle) {
*vc = data->vc;
return 0;
}
bool vc_client_is_valid_by_uid(unsigned int uid);
-int vc_client_get_handle(unsigned int uid, vc_h* vc);
+int vc_client_get_handle(int pid, vc_h* vc);
/*
* set/get callback function
extern int __vc_cb_error(int reason, int daemon_pid, char* msg);
+extern int __vc_cb_error_to_app(int pid, int reason, char* msg);
+
extern void __vc_cb_result();
extern int __vc_cb_service_state(int state);
SLOG(LOG_DEBUG, TAG_VCC, "@@@");
} /* VCD_METHOD_ERROR */
+ else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR_TO_APP)) {
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Error and send to client app");
+ int pid;
+ int reason;
+ char* err_msg;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_INT32, &reason,
+ DBUS_TYPE_STRING, &err_msg,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_VCC, "@@ vc Get Error message : Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", reason, pid, err_msg);
+ __vc_cb_error_to_app(pid, reason, err_msg);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+ } /* VCD_METHOD_ERROR_TO_APP */
+
else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_FEEDBACK_STREAMING)) {
SLOG(LOG_INFO, TAG_VCC, "@@@ Get TTS feedback streaming");
int utt_id;
#define VCD_METHOD_RESULT "vcd_method_result"
#define VCD_METHOD_ERROR "vcd_method_error"
+#define VCD_METHOD_ERROR_TO_APP "vcd_method_error_to_app"
#define VCD_METHOD_HELLO "vcd_method_hello"
#define VCD_METHOD_SET_SERVICE_STATE "vcd_method_set_service_state"
#define VCD_METHOD_SEND_MANAGER_PID "vcd_method_send_manager_pid"
return 0;
}
+int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg)
+{
+ if (NULL == err_msg) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Input parameter is NULL");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ if (VCD_ERROR_NONE != __dbus_check()) {
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ SLOG(LOG_ERROR, TAG_VCD, "@@ Send error to app(%d)", pid);
+
+ DBusMessage* msg = __get_message(pid, VCD_METHOD_ERROR_TO_APP, VCD_CLIENT_TYPE_NORMAL);
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &reason, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ if (TRUE != dbus_connection_send(g_conn_sender, msg, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send");
+ dbus_message_unref(msg);
+ return VCD_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "@@ Send error to app: pid(%d), reason(%d), Error Msg(%s)", pid, reason, err_msg);
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ dbus_message_unref(msg);
+
+ return VCD_ERROR_NONE;
+}
+
int vcdc_send_request_set_private_data(int pid, const char* key, const char* data)
{
if (0 != __dbus_check()) {
int vcdc_send_error_signal_to_manager(int manager_pid, int reason, char *err_msg);
+int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg);
+
int vcdc_send_service_state(vcd_state_e state);
int vcdc_send_dialog(int manger_pid, int pid, const char* disp_text, const char* utt_text, int continuous);
}
int ret = VCD_ERROR_NONE;
- ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg);
+ if (VCE_ERROR_TTS_FAILED == error) {
+ int pid = g_current_uid / 1000;
+ ret = vcdc_send_error_signal_to_app(pid, error, error_msg);
+ } else {
+ ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg);
+ ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL);
+ }
+
if (VCD_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send error signal");
}
error_msg = NULL;
}
- ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL);
-
return ret;
}
SLOG(LOG_INFO, TAG_VCD, "[Server SUCCESS] request tts, pid(%d), utt_id(%d)", pid, utt_id);
}
- return 0;
+ /* Set service state */
+ vcd_config_set_service_state(VCD_STATE_READY);
+
+ return VCD_ERROR_NONE;
}
int vcd_server_get_tts_audio_format(int pid, int* rate, int* channel, int* audio_type)