}
}
+static int __stt_dbus_send_message_without_reply(DBusMessage* msg, char* method)
+{
+ int ret = STT_ERROR_NONE;
+ if (g_conn_sender) {
+ dbus_message_set_no_reply(msg, TRUE);
+
+ if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt dbus %s message : Out Of Memory !", method);
+ ret = STT_ERROR_OUT_OF_MEMORY;
+ //LCOV_EXCL_STOP
+ } else {
+ dbus_connection_flush(g_conn_sender);
+ }
+ } else {
+ //LCOV_EXCL_START
+ SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender); //LCOV_EXCL_LINE
+ ret = STT_ERROR_OPERATION_FAILED;
+ //LCOV_EXCL_STOP
+ }
+
+ dbus_message_unref(msg);
+ msg = NULL;
+ SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Send dbus %s message, ret(%d)", method, ret); //LCOV_EXCL_LINE
+
+ return ret;
+}
+
+static DBusMessage* __stt_dbus_send_message_with_reply_and_block(DBusMessage* msg, int waiting_time)
+{
+ if (!g_conn_sender) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] g_conn_sender is NULL");
+ return NULL;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, waiting_time, &err);
+ dbus_message_unref(msg);
+ 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
+ }
+ return result_msg;
+}
+
+static int __stt_dbus_send_message_and_get_result(DBusMessage* msg, int waiting_time, const char* method)
+{
+ DBusError err;
+ dbus_error_init(&err);
+ int result = STT_ERROR_OPERATION_FAILED;
+
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, waiting_time);
+ 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 method(%s) : result = %d", method, result);
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< stt method(%s) : result = %d", method, 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;
+ }
+
+ return result;
+}
+
int stt_dbus_request_hello(unsigned int uid)
{
stt_client_s* client = stt_client_get_by_uid(uid);
dbus_error_init(&err);
DBusMessage* msg = NULL;
- DBusMessage* result_msg = NULL;
int result = 0;
if (NULL == g_conn_sender) {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request stt hello : uid(%u)", uid);
}
- if (g_conn_sender) {
- result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_time, &err);
- dbus_message_unref(msg);
- msg = NULL;
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_short_time);
+ if (NULL != result_msg) {
+ dbus_message_unref(result_msg);
+ result_msg = NULL;
+
if (dbus_error_is_set(&err)) {
+ //LCOV_EXCL_START
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
dbus_error_free(&err);
+ //LCOV_EXCL_STOP
}
- if (NULL != result_msg) {
- dbus_message_unref(result_msg);
- result_msg = NULL;
-
- if (dbus_error_is_set(&err)) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- //LCOV_EXCL_STOP
- }
-
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello");
- } else {
- if (dbus_error_is_set(&err)) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- //LCOV_EXCL_STOP
- }
-
- result = STT_ERROR_TIMED_OUT;
- }
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello");
} else {
- SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender); //LCOV_EXCL_LINE
stt_dbus_reconnect();
result = STT_ERROR_OPERATION_FAILED;
}
DBusError err;
dbus_error_init(&err);
- DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
- if (g_conn_sender) {
- result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
- dbus_message_unref(msg);
- msg = NULL;
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_time);
+ if (NULL != result_msg) {
+ int int_silence_supported = 0;
+ int int_credential_needed = 0;
+ dbus_message_get_args(result_msg, &err,
+ DBUS_TYPE_INT32, &result,
+ DBUS_TYPE_INT32, &int_silence_supported,
+ DBUS_TYPE_INT32, &int_credential_needed,
+ DBUS_TYPE_INVALID);
+
+ *silence_supported = (bool)(int_silence_supported);
+ *credential_needed = (bool)(int_credential_needed);
+
if (dbus_error_is_set(&err)) {
//LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
dbus_error_free(&err);
+ result = STT_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
- if (NULL != result_msg) {
- int int_silence_supported = 0;
- int int_credential_needed = 0;
- dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INT32, &int_silence_supported,
- DBUS_TYPE_INT32, &int_credential_needed,
- DBUS_TYPE_INVALID);
-
- *silence_supported = (bool)(int_silence_supported);
- *credential_needed = (bool)(int_credential_needed);
+ if (0 == result) {
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d), credential(%d)",
+ result, *silence_supported, *credential_needed);
- 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
+ stt_client_s* client = stt_client_get_by_uid(uid);
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_STTC, "Fail to get STT client");
+ dbus_message_unref(result_msg);
+ result_msg = NULL;
+ return STT_ERROR_OPERATION_FAILED;
}
- if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d), credential(%d)",
- result, *silence_supported, *credential_needed);
+ if (STT_ERROR_SERVICE_RESET != client->reason) {
+ /* add a rule for daemon error */
+ char rule_err[256] = {0, };
- stt_client_s* client = stt_client_get_by_uid(uid);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "Fail to get STT client");
+ snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", g_server_service_interface);
+ dbus_bus_add_match(g_conn_listener, rule_err, &err);
+ dbus_connection_flush(g_conn_listener);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
+ dbus_error_free(&err);
dbus_message_unref(result_msg);
result_msg = NULL;
return STT_ERROR_OPERATION_FAILED;
}
-
- if (STT_ERROR_SERVICE_RESET != client->reason) {
- /* add a rule for daemon error */
- char rule_err[256] = {0, };
-
- snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", g_server_service_interface);
- dbus_bus_add_match(g_conn_listener, rule_err, &err);
- dbus_connection_flush(g_conn_listener);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
- dbus_error_free(&err);
- dbus_message_unref(result_msg);
- result_msg = NULL;
- return STT_ERROR_OPERATION_FAILED;
- }
- }
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d", result); //LCOV_EXCL_LINE
}
-
- dbus_message_unref(result_msg);
- result_msg = NULL;
} else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL"); //LCOV_EXCL_LINE
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d", result); //LCOV_EXCL_LINE
}
- } else {
- SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender); //LCOV_EXCL_LINE
- result = STT_ERROR_OPERATION_FAILED;
- }
- if (msg != NULL) {
- dbus_message_unref(msg);
- msg = NULL;
+ dbus_message_unref(result_msg);
+ result_msg = NULL;
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL"); //LCOV_EXCL_LINE
+ stt_dbus_reconnect();
+ result = STT_ERROR_TIMED_OUT;
}
return result;
dbus_message_append_args(msg, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
- DBusMessage* result_msg;
- int result = STT_ERROR_OPERATION_FAILED;
-
- result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_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 finalize : result = %d", result);
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt finalize : 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 result = __stt_dbus_send_message_and_get_result(msg, g_waiting_short_time, STT_METHOD_FINALIZE);
return result;
}
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)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_time);
if (NULL != result_msg) {
int int_silence_supported = 0;
int int_credential_needed = 0;
DBusError err;
dbus_error_init(&err);
- DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
int available = -1;
- 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)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_time);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
DBusError err;
dbus_error_init(&err);
- DBusMessage* result_msg;
DBusMessageIter args;
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)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_time);
if (NULL != result_msg) {
if (dbus_message_iter_init(result_msg, &args)) {
/* Get result */
DBusError err;
dbus_error_init(&err);
- DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
char* temp_lang = NULL;
- 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)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_time);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
return STT_ERROR_OPERATION_FAILED;
}
- 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 set private data : result = %d", result);
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set private data : 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 result = __stt_dbus_send_message_and_get_result(msg, g_waiting_time, STT_METHOD_SET_PRIVATE_DATA);
return result;
}
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
- }
-
char* temp = NULL;
+
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_time);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
DBusError err;
dbus_error_init(&err);
- DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
int result_support = -1;
- 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
- }
-
+ DBusMessage* result_msg = __stt_dbus_send_message_with_reply_and_block(msg, g_waiting_time);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
DBUS_TYPE_STRING, &file,
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 %s: result = %d", method_string, result);
- } else {
- 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
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
- }
-
+ int result = __stt_dbus_send_message_and_get_result(msg, g_waiting_time, method_string);
return result;
}
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, "<<<< %s : result = %d", method_string, result);
- } else {
- 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
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
- }
-
+ int result = __stt_dbus_send_message_and_get_result(msg, g_waiting_time, method_string);
return result;
}
return ret;
}
-static int __stt_dbus_send_message_without_reply(DBusMessage* msg, char* method)
-{
- int ret = STT_ERROR_NONE;
- if (g_conn_sender) {
- dbus_message_set_no_reply(msg, TRUE);
-
- if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt dbus %s message : Out Of Memory !", method);
- ret = STT_ERROR_OUT_OF_MEMORY;
- //LCOV_EXCL_STOP
- } else {
- dbus_connection_flush(g_conn_sender);
- }
- } else {
- //LCOV_EXCL_START
- SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender); //LCOV_EXCL_LINE
- ret = STT_ERROR_OPERATION_FAILED;
- //LCOV_EXCL_STOP
- }
-
- dbus_message_unref(msg);
- msg = NULL;
- SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Send dbus %s message, ret(%d)", method, ret); //LCOV_EXCL_LINE
-
- return ret;
-}
-
int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential)
{
if (NULL == lang || NULL == type || NULL == appid) {
DBUS_TYPE_STRING, &appid,
DBUS_TYPE_STRING, &temp,
DBUS_TYPE_INVALID);
-#if 1
+
int ret = __stt_dbus_send_message_without_reply(msg, STT_METHOD_START);
free(temp);
temp = NULL;
return ret;
-#else
- 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);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
- if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- result = STT_ERROR_OPERATION_FAILED;
- }
- dbus_message_unref(result_msg);
-
- if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt start : result = %d ", result);
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt start : result = %d ", result);
- }
- } else {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
- }
-
- return result;
-#endif
}
int stt_dbus_request_stop(unsigned int uid)
dbus_message_append_args(msg,
DBUS_TYPE_UINT32, &uid,
DBUS_TYPE_INVALID);
-#if 1
+
int ret = __stt_dbus_send_message_without_reply(msg, STT_METHOD_STOP);
return ret;
-#else
- 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);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
- if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- result = STT_ERROR_OPERATION_FAILED;
- }
- dbus_message_unref(result_msg);
-
- if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt stop : result = %d ", result);
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt stop : result = %d ", result);
- }
- } else {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
- }
-
- return result;
-#endif
}
int stt_dbus_request_cancel(unsigned int uid)
dbus_message_append_args(msg,
DBUS_TYPE_UINT32, &uid,
DBUS_TYPE_INVALID);
-#if 1
+
int ret = __stt_dbus_send_message_without_reply(msg, STT_METHOD_CANCEL);
return ret;
-#else
- 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);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
- if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- result = STT_ERROR_OPERATION_FAILED;
- }
- dbus_message_unref(result_msg);
-
- if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt cancel : result = %d ", result);
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "<<<< stt cancel : result = %d ", result);
- }
- } else {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
- stt_dbus_reconnect();
- result = STT_ERROR_TIMED_OUT;
- }
-
- return result;
-#endif
}
//LCOV_EXCL_START