bundle_get_str(msg, TTS_BUNDLE_METHOD, &method);
if (0 == strncmp(TTSD_METHOD_HELLO, method, strlen(TTSD_METHOD_HELLO))) {
- bundle_get_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, &val);
- if (val) {
+ char* credential_needed = NULL;
+ char* ret = NULL;
+ bundle_get_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, &credential_needed);
+ bundle_get_str(msg, TTS_BUNDLE_REASON, &ret);
+
+ if (NULL != credential_needed && NULL != ret) {
tts_client_set_start_listening(uid, true);
- tts_core_receive_hello(uid, 0, atoi(val));
+ tts_core_receive_hello(uid, atoi(ret), atoi(credential_needed));
+ } else {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get message(TTSD_METHOD_HELLO). pid(%d) uid(%d)", pid, uid);
}
} else if (0 == strncmp(TTSD_METHOD_UTTERANCE_STARTED, method, strlen(TTSD_METHOD_UTTERANCE_STARTED))) {
bundle_get_str(msg, TTS_BUNDLE_UTTID, &val);
if (reason && uttid) {
tts_core_notify_error_async(client, atoi(reason), atoi(uttid), err_msg);
}
- }
- else {
+ } else {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid msg");
}
}
{
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS REGISTER CALLBACK uid(%d)", uid);
- bool credential_needed = false;
- if (0 != ttsd_server_initialize(pid, uid, TTS_IPC_METHOD_TIDL, &credential_needed)) {
- SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize");
- return;
+ bool is_initialized = false;
+ ttsd_server_is_already_initialized(pid, uid, &is_initialized);
+
+ int ret = -1;
+ int credential_needed = 0;
+ if (false == is_initialized) {
+ bool is_credential_needed = false;
+ ret = ttsd_server_initialize(pid, uid, TTS_IPC_METHOD_TIDL, &is_credential_needed);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize, ret(%d)", ret);
+ }
+
+ credential_needed = is_credential_needed ? 1 : 0;
+ } else {
+ ret = TTS_ERROR_ALREADY_INITIALIZED;
+ credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED;
}
if (0 != ttsd_data_set_notify_h(uid, callback, NULL)) {
}
SLOG(LOG_INFO, tts_tag(), "create player instance");
- ttsdc_tidl_send_hello(pid, uid, (int)credential_needed);
+ ttsdc_tidl_send_hello(pid, uid, ret, credential_needed);
SLOG(LOG_ERROR, tts_tag(), "<<<<<<<<<<<");
return TTSE_ERROR_NONE;
}
-int ttsdc_tidl_send_hello(int pid, int uid, int credential_needed)
+int ttsdc_tidl_send_hello(int pid, int uid, int ret, int credential_needed)
{
SLOG(LOG_INFO, tts_tag(), "[TIDL] ttsdc_tidl_send_hello : pid(%d), uid(%d), credential_needed(%d)", pid, uid, credential_needed);
char tmp_val[10] = {0, };
+ char ret_val[12] = {0, };
+ snprintf(tmp_val, 10, "%d", credential_needed);
+ snprintf(ret_val, 12, "%d", ret);
+
bundle* msg = bundle_create();
- snprintf(tmp_val, 10, "%d", (int)credential_needed);
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL] Fail to create bundle: pid(%d), uid(%d)", pid, uid);
+ return TTSD_ERROR_OUT_OF_MEMORY;
+ }
+
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);
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTSD SEND HELLO MSG");
__send_msg(pid, uid, msg);
- return TTSE_ERROR_NONE;
+ bundle_free(msg);
+ return TTSD_ERROR_NONE;
}
static int __initialize_cb(rpc_port_stub_tts_context_h context, int pid, int uid, bool *credential_needed, void *user_data)
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTSD SEND MSG");
__send_msg(pid, uid, msg);
+ bundle_free(msg);
return TTSE_ERROR_NONE;
}
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTSD SEND ERROR MSG");
__send_msg(pid, uid, msg);
+ bundle_free(msg);
return TTSE_ERROR_NONE;
}