extern int __stt_cb_speech_status(unsigned int uid, int status);
+
+static char* __convert_stt_set_sound_method_into_char(stt_set_sound_method_e method)
+{
+ switch (method) {
+ case STT_SET_START_SOUND:
+ return STT_METHOD_SET_START_SOUND;
+ case STT_UNSET_START_SOUND:
+ return STT_METHOD_UNSET_START_SOUND;
+ case STT_SET_STOP_SOUND:
+ return STT_METHOD_SET_STOP_SOUND;
+ case STT_UNSET_STOP_SOUND:
+ return STT_METHOD_UNSET_STOP_SOUND;
+ default:
+ SLOG(LOG_ERROR, TAG_STTC, "Unsupported set sound method, method(%d)", method); //LCOV_EXCL_LINE
+ }
+ return NULL;
+}
+
//LCOV_EXCL_START
char* __stt_get_default_engine()
{
return result;
}
-int stt_dbus_request_set_start_sound(unsigned int uid, const char* file)
+static int __stt_dbus_request_set_sound(int method, unsigned int uid, const char* file)
{
if (NULL == file) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL"); //LCOV_EXCL_LINE
return STT_ERROR_INVALID_PARAMETER;
}
+ char* method_string = __convert_stt_set_sound_method_into_char(method);
DBusMessage* msg;
g_server_service_name,
g_server_service_object,
g_server_service_interface,
- STT_METHOD_SET_START_SOUND);
+ method_string);
if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set start sound : Fail to make message"); //LCOV_EXCL_LINE
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> %s : Fail to make message", method_string); //LCOV_EXCL_LINE
return STT_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set start sound : uid(%u) file(%s)", uid, file);
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> %s : uid(%u) file(%s)", method_string, uid, file);
}
dbus_message_append_args(msg,
result_msg = NULL;
if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set start sound : result = %d", result);
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt %s: result = %d", method_string, result);
} else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set start sound : result = %d", result); //LCOV_EXCL_LINE
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< stt %s : result = %d", method_string, result); //LCOV_EXCL_LINE
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL"); //LCOV_EXCL_LINE
return result;
}
-int stt_dbus_request_unset_start_sound(unsigned int uid)
+static int __stt_dbus_request_unset_sound(int method, unsigned int uid)
{
DBusMessage* msg;
+ char* method_string = __convert_stt_set_sound_method_into_char(method);
msg = dbus_message_new_method_call(
g_server_service_name,
g_server_service_object,
g_server_service_interface,
- STT_METHOD_UNSET_START_SOUND);
+ method_string);
if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset start sound : Fail to make message"); //LCOV_EXCL_LINE
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> %s : Fail to make message", method_string); //LCOV_EXCL_LINE
return STT_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset start sound : uid(%u)", uid);
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> %s : uid(%u)", method_string, uid);
}
dbus_message_append_args(msg,
result_msg = NULL;
if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset start sound : result = %d", result);
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< %s : result = %d", method_string, result);
} else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt unset start sound : result = %d", result); //LCOV_EXCL_LINE
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< %s : result = %d", method_string, result); //LCOV_EXCL_LINE
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL"); //LCOV_EXCL_LINE
return result;
}
-int stt_dbus_request_set_stop_sound(unsigned int uid, const char* file)
+int stt_dbus_request_set_start_sound(unsigned int uid, const char* file)
{
- if (NULL == file) {
- SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- DBusMessage* msg;
-
- msg = dbus_message_new_method_call(
- g_server_service_name,
- g_server_service_object,
- g_server_service_interface,
- STT_METHOD_SET_STOP_SOUND);
-
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set stop sound : Fail to make message"); //LCOV_EXCL_LINE
- return STT_ERROR_OPERATION_FAILED;
- } else {
- SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set stop sound : uid(%u) file(%s)", uid, file);
+ int ret = __stt_dbus_request_set_sound(STT_SET_START_SOUND, uid, file);
+ if (STT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "Fail to request set start sound, uid(%d), file(%s)", uid, file);
}
- dbus_message_append_args(msg,
- DBUS_TYPE_UINT32, &uid,
- DBUS_TYPE_STRING, &file,
- DBUS_TYPE_INVALID);
-
- DBusError err;
- dbus_error_init(&err);
-
- DBusMessage* result_msg;
- int result = STT_ERROR_OPERATION_FAILED;
+ return ret;
+}
- result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
- dbus_message_unref(msg);
- msg = NULL;
- if (dbus_error_is_set(&err)) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- //LCOV_EXCL_STOP
+int stt_dbus_request_unset_start_sound(unsigned int uid)
+{
+ int ret = __stt_dbus_request_unset_sound(STT_UNSET_START_SOUND, uid);
+ if (STT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "Fail to request unset start sound, uid(%d)", uid);
}
- if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set(&err)) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- result = STT_ERROR_OPERATION_FAILED;
- //LCOV_EXCL_STOP
- }
- dbus_message_unref(result_msg);
- result_msg = NULL;
+ return ret;
+}
- if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set stop sound : result = %d", result);
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set stop sound : result = %d", result); //LCOV_EXCL_LINE
- }
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL"); //LCOV_EXCL_LINE
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
+int stt_dbus_request_set_stop_sound(unsigned int uid, const char* file)
+{
+ int ret = __stt_dbus_request_set_sound(STT_SET_STOP_SOUND, uid, file);
+ if (STT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "Fail to request set stop sound, uid(%d), file(%s)", uid, file);
}
- return result;
+ return ret;
}
int stt_dbus_request_unset_stop_sound(unsigned int uid)
{
- DBusMessage* msg;
-
- msg = dbus_message_new_method_call(
- g_server_service_name,
- g_server_service_object,
- g_server_service_interface,
- STT_METHOD_UNSET_STOP_SOUND);
-
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset stop sound : Fail to make message"); //LCOV_EXCL_LINE
- return STT_ERROR_OPERATION_FAILED;
- } else {
- SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset stop sound : uid(%u)", uid);
- }
-
- dbus_message_append_args(msg,
- DBUS_TYPE_UINT32, &uid,
- DBUS_TYPE_INVALID);
-
- DBusError err;
- dbus_error_init(&err);
-
- DBusMessage* result_msg;
- int result = STT_ERROR_OPERATION_FAILED;
-
- result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
- dbus_message_unref(msg);
- msg = NULL;
- if (dbus_error_is_set(&err)) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- //LCOV_EXCL_STOP
- }
-
- if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set(&err)) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- result = STT_ERROR_OPERATION_FAILED;
- //LCOV_EXCL_STOP
- }
- dbus_message_unref(result_msg);
- result_msg = NULL;
-
- if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset stop sound : result = %d", result);
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt unset stop sound : result = %d", result); //LCOV_EXCL_LINE
- }
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL"); //LCOV_EXCL_LINE
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
+ int ret = __stt_dbus_request_unset_sound(STT_UNSET_STOP_SOUND, uid);
+ if (STT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "Fail to request unset stop sound, uid(%d)", uid);
}
- return result;
+ return ret;
}
static int __stt_dbus_send_message_without_reply(DBusMessage* msg, char* method)