// TODO: make function duplicated block
/* do request initialize */
bool credential_needed = false;
+ tts_service_state_e service_state = TTS_SERVICE_STATE_READY;
tts_mode_e mode = tts_client_get_mode(client);
int registered_callback_mask = tts_client_get_registered_event_mask(client);
- int ret = tts_ipc_request_initialize(uid, mode, registered_callback_mask, &credential_needed);
+ int ret = tts_ipc_request_initialize(uid, mode, registered_callback_mask, &service_state, &credential_needed);
if (TTS_ERROR_ENGINE_NOT_FOUND == ret || TTS_ERROR_PERMISSION_DENIED == ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to initialize. ret(%d/%s)", ret, get_error_message(ret));
tts_core_notify_error_async(client, ret, -1, NULL);
SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Get Hello");
unsigned int uid;
- int ret;
- int credential_needed;
+ int ret = TTS_ERROR_NONE;
+ int service_state = (int)TTS_SERVICE_STATE_READY;
+ int credential_needed = 0;
dbus_message_get_args(msg, &err,
DBUS_TYPE_UINT32, &uid,
DBUS_TYPE_INT32, &ret,
+ DBUS_TYPE_INT32, &service_state,
DBUS_TYPE_INT32, &credential_needed,
DBUS_TYPE_INVALID);
return result;
}
-int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed)
+int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed)
{
DBusMessage* msg;
DBusError err;
dbus_error_free(&err);
}
- int temp = 0;
+ int tmp_credential_needed = 0;
+ int tmp_service_state = -1;
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INT32, &temp,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_INT32, &result,
+ DBUS_TYPE_INT32, &tmp_service_state,
+ DBUS_TYPE_INT32, &tmp_credential_needed,
+ DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)", err.message);
dbus_message_unref(result_msg);
if (0 == result) {
- *credential_needed = (bool)temp;
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : result = %d, credential_needed(%d)", result, *credential_needed);
+ *service_state = (tts_service_state_e)tmp_service_state;
+ *credential_needed = (bool)tmp_credential_needed;
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : result = %d, service_state(%d), credential_needed(%d)", result, tmp_service_state, tmp_credential_needed);
/* add a rule for daemon error */
tts_client_s* client = tts_client_get_by_uid(uid);
int tts_dbus_request_hello_sync(unsigned int uid);
-int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed);
+int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed);
int tts_dbus_request_finalize(unsigned int uid);
return g_vtable[REQUEST_HELLO_SYNC](uid);
}
-int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed)
+int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed)
{
SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_initialize");
RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
- return g_vtable[REQUEST_INITIALIZE](uid, mode, registered_event_mask, credential_needed);
+ return g_vtable[REQUEST_INITIALIZE](uid, mode, registered_event_mask, service_state, credential_needed);
}
int tts_ipc_request_finalize(unsigned int uid)
int tts_ipc_request_hello_sync(unsigned int uid);
-int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed);
+int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed);
int tts_ipc_request_finalize(unsigned int uid);
if (0 == strncmp(TTSD_METHOD_HELLO, method, strlen(TTSD_METHOD_HELLO))) {
char* credential_needed = NULL;
+ char* service_state = NULL;
char* ret = NULL;
+
bundle_get_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, &credential_needed);
+ bundle_get_str(msg, TTS_BUNDLE_CURRENT_STATE, &service_state);
bundle_get_str(msg, TTS_BUNDLE_REASON, &ret);
if (NULL != credential_needed && NULL != ret) {
return TTS_ERROR_NONE;
}
-int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed)
+int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed)
{
SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_initialize");
RETVM_IF(!info->connected, TTS_ERROR_IO_ERROR, "[ERROR] Not Connected");
- bool temp;
- int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, (int)mode, registered_event_mask, &temp);
+ bool tmp_credential_needed = false;
+ int tmp_service_state = -1;
+ int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, (int)mode, registered_event_mask, &tmp_service_state, &tmp_credential_needed);
int exception = get_last_result();
if (RPC_PORT_ERROR_NONE != exception) {
ret = __convert_and_handle_tidl_error(exception, info);
return ret;
}
- *credential_needed = temp;
+ *credential_needed = tmp_credential_needed;
+ *service_state = (tts_service_state_e)tmp_service_state;
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : credential_needed(%d)", *credential_needed);
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : service_state(%d), credential_needed(%d)", tmp_service_state, tmp_credential_needed);
return TTS_ERROR_NONE;
}
int tts_tidl_request_hello_sync(unsigned int uid);
-int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed);
+int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed);
int tts_tidl_request_finalize(unsigned int uid);
return NULL;
}
-int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int credential_needed)
+int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed)
{
if (NULL == g_conn_sender) {
SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
SLOG(LOG_INFO, tts_tag(), "<<<< [Dbus] Send hello message : uid(%u), ret(%d), credential_needed(%d)", uid, ret, credential_needed);
}
- dbus_message_append_args(msg, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &credential_needed, DBUS_TYPE_INVALID);
+ dbus_message_append_args(msg,
+ DBUS_TYPE_UINT32, &uid,
+ DBUS_TYPE_INT32, &ret,
+ DBUS_TYPE_INT32, &service_state,
+ DBUS_TYPE_INT32, &credential_needed,
+ DBUS_TYPE_INVALID);
if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send");
int ttsd_dbus_close_connection();
-int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int credential_needed);
+int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed);
int ttsdc_dbus_send_utt_start_message(int pid, unsigned int uid, int uttid);
SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : pid(%d), uid(%u), mode(%d)", pid, uid, mode);
bool is_initialized = false;
bool is_credential_needed = false;
+ int service_state = TTSD_STATE_INVALID;
int credential_needed = 0;
int ret = -1;
ret = TTS_ERROR_ALREADY_INITIALIZED;
credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED;
}
- SLOG(LOG_INFO, tts_tag(), "[INFO] send_hello. pid(%d), uid(%u), ret(%d), credential_needed(%d)", pid, uid, ret, credential_needed);
- ttsdc_dbus_send_hello(pid, uid, ret, credential_needed);
+ SLOG(LOG_INFO, tts_tag(), "[INFO] send_hello. pid(%d), uid(%u), ret(%d), service_state(%d), credential_needed(%d)",
+ pid, uid, ret, service_state, credential_needed);
+
+ ttsdc_dbus_send_hello(pid, uid, ret, service_state, credential_needed);
}
return 0;
DBusMessage* reply;
reply = dbus_message_new_method_return(msg);
- int temp = (int)credential_needed;
+ int tmp_credential_needed = (int)credential_needed;
+ int tmp_service_state = -1;
SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, (int)credential_needed);
if (NULL != reply) {
dbus_message_append_args(reply,
DBUS_TYPE_INT32, &ret,
- DBUS_TYPE_INT32, &temp,
+ DBUS_TYPE_INT32, &tmp_service_state,
+ DBUS_TYPE_INT32, &tmp_credential_needed,
DBUS_TYPE_INVALID);
if (0 == ret) {
int ttsd_ipc_close_connection();
-int ttsdc_ipc_send_hello(int pid, unsigned int uid, int ret, int credential_needed);
+int ttsdc_ipc_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed);
int ttsdc_ipc_send_utt_start_message(int pid, unsigned int uid, int uttid);
int ret = -1;
int credential_needed = 0;
+ int service_state = TTSD_STATE_INVALID;
+
if (false == is_initialized) {
bool is_credential_needed = false;
ret = ttsd_server_initialize(pid, u_uid, mode, registered_event_mask, TTS_IPC_METHOD_TIDL, &is_credential_needed);
pthread_mutex_unlock(&g_tidl_proxy_infos_mutex);
SLOG(LOG_INFO, tts_tag(), "create player instance");
- ttsdc_tidl_send_hello(pid, u_uid, ret, credential_needed);
+ ttsdc_tidl_send_hello(pid, u_uid, ret, service_state, credential_needed);
SLOG(LOG_ERROR, tts_tag(), "<<<<<<<<<<<");
return;
return TTSD_ERROR_NONE;
}
-int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int credential_needed)
+int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed)
{
- SLOG(LOG_INFO, tts_tag(), "[TIDL] ttsdc_tidl_send_hello : pid(%d), uid(%u), credential_needed(%d)", pid, uid, credential_needed);
+ SLOG(LOG_INFO, tts_tag(), "[TIDL] ttsdc_tidl_send_hello : pid(%d), uid(%u), service_state(%d), credential_needed(%d)",
+ pid, uid, service_state, credential_needed);
+
+ char credential_needed_str[12] = {0, };
+ char service_state_str[12] = {0, };
+ char ret_str[12] = {0, };
- char tmp_val[10] = {0, };
- char ret_val[12] = {0, };
- snprintf(tmp_val, 10, "%d", credential_needed);
- snprintf(ret_val, 12, "%d", ret);
+ snprintf(credential_needed_str, 12, "%d", credential_needed);
+ snprintf(service_state_str, 12, "%d", service_state);
+ snprintf(ret_str, 12, "%d", ret);
bundle* msg = bundle_create();
if (NULL == msg) {
}
bundle_add_str(msg, TTS_BUNDLE_METHOD, TTSD_METHOD_HELLO);
- bundle_add_str(msg, TTS_BUNDLE_REASON, ret_val);
- bundle_add_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, tmp_val);
+ bundle_add_str(msg, TTS_BUNDLE_REASON, ret_str);
+ bundle_add_str(msg, TTS_BUNDLE_CURRENT_STATE, service_state_str);
+ bundle_add_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, credential_needed_str);
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTSD SEND HELLO MSG");
__send_msg(pid, uid, msg);
return TTSD_ERROR_NONE;
}
-static int __initialize_cb(rpc_port_stub_tts_context_h context, int pid, int uid, int mode, int registered_event_mask, bool *credential_needed, void *user_data)
+static int __initialize_cb(rpc_port_stub_tts_context_h context, int pid, int uid, int mode, int registered_event_mask, int *service_state, bool *credential_needed, void *user_data)
{
unsigned int u_uid = (unsigned int)uid;
SECURE_SLOG(LOG_ERROR, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u), mode(%d)", pid, u_uid, mode);
int ttsd_tidl_close_connection();
-int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int credential_needed);
+int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed);
int ttsdc_tidl_send_utt_start_message(int pid, unsigned int uid, int uttid);
void register_cb(int pid, int uid, int mode, int registered_event_mask, notify_cb callback) async;
int register_cb_sync(int pid, int uid, notify_cb callback);
- int initialize(in int pid, in int uid, in int mode, in int registered_event_mask, out bool credential_needed);
+ int initialize(in int pid, in int uid, in int mode, in int registered_event_mask, out int service_state, out bool credential_needed);
int finalize(in int uid);
int add_text(int uid, string text, string lang, int vctype, int speed, int uttid, string credential);
int stop(in int uid);