return STT_ERROR_NONE;
}
+static bool __stt_is_necessary_to_retry_dbus_request(int count, int return_value)
+{
+ bool ret = true;
+ if (STT_ERROR_TIMED_OUT != return_value) {
+ ret = false;
+ } else {
+ SLOG(LOG_WARN, TAG_STTC, "[WARNING][%d] retry : %s", count, __stt_get_error_code(ret));
+ usleep(10000);
+ if (STT_RETRY_COUNT == count) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+ ret = false;
+ }
+ }
+ return ret;
+}
+
int stt_set_private_data(stt_h stt, const char* key, const char* data)
{
stt_client_s* client = NULL;
ret = stt_dbus_request_set_private_data(client->uid, key, data);
if (0 != ret) {
//LCOV_EXCL_START
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set private data : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry : %s", __stt_get_error_code(ret));
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
//LCOV_EXCL_STOP
}
}
ret = stt_dbus_request_get_private_data(client->uid, key, data);
if (0 != ret) {
//LCOV_EXCL_START
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get private data : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry : %s", __stt_get_error_code(ret));
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
//LCOV_EXCL_STOP
}
}
while (0 != ret) {
ret = stt_dbus_request_set_current_engine(client->uid, client->current_engine_id, &silence_supported, &credential_needed);
if (0 != ret) {
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set current engine : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
} else {
SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", client->current_engine_id);
ret = stt_dbus_request_is_recognition_type_supported(client->uid, type, support);
if (0 != ret) {
//LCOV_EXCL_START
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get recognition type supported : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
//LCOV_EXCL_STOP
} else {
SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] recognition type is %s", *support ? "true " : "false");
ret = stt_dbus_request_set_start_sound(client->uid, filename);
if (0 != ret) {
//LCOV_EXCL_START
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set start sound : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
//LCOV_EXCL_STOP
} else {
SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Set start sound : %s", filename);
ret = stt_dbus_request_unset_start_sound(client->uid);
if (0 != ret) {
//LCOV_EXCL_START
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to unset start sound : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
//LCOV_EXCL_STOP
} else {
SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Unset start sound");
ret = stt_dbus_request_set_stop_sound(client->uid, filename);
if (0 != ret) {
//LCOV_EXCL_START
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set stop sound : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
//LCOV_EXCL_STOP
} else {
SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Set stop sound : %s", filename);
ret = stt_dbus_request_unset_stop_sound(client->uid);
if (0 != ret) {
//LCOV_EXCL_START
- if (STT_ERROR_TIMED_OUT != ret) {
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to unset stop sound : %s", __stt_get_error_code(ret));
return ret;
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
- usleep(10000);
- count++;
- if (STT_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
- return ret;
- }
}
+ count++;
//LCOV_EXCL_STOP
} else {
SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Unset stop sound");