Remove duplicates regarding dbus_connection_send_with_reply_and_block 32/276932/2
authorwn.jang <wn.jang@samsung.com>
Tue, 28 Jun 2022 02:50:54 +0000 (11:50 +0900)
committerwn.jang <wn.jang@samsung.com>
Tue, 28 Jun 2022 04:40:41 +0000 (13:40 +0900)
Change-Id: Iaec79cc7a2801fd10e45349bff77ea96552763de

client/stt_dbus.c

index 79066d7..1ab6b2e 100644 (file)
@@ -685,6 +685,92 @@ void __stt_dbus_service_free()
        }
 }
 
+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);
@@ -695,7 +781,6 @@ int stt_dbus_request_hello(unsigned int uid)
        dbus_error_init(&err);
 
        DBusMessage* msg = NULL;
-       DBusMessage* result_msg = NULL;
        int result = 0;
 
        if (NULL == g_conn_sender) {
@@ -775,39 +860,20 @@ int stt_dbus_request_hello(unsigned int uid)
                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;
        }
@@ -842,87 +908,67 @@ int stt_dbus_request_initialize(unsigned int uid, bool* silence_supported, bool*
        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;
@@ -964,46 +1010,7 @@ int stt_dbus_request_finalize(unsigned int uid)
 
        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;
 }
 
@@ -1034,17 +1041,9 @@ int stt_dbus_request_set_current_engine(unsigned int uid, const char* engine_id,
        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;
@@ -1112,18 +1111,10 @@ int stt_dbus_request_check_app_agreed(unsigned int uid, const char* appid, bool*
        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,
@@ -1180,18 +1171,10 @@ int stt_dbus_request_get_support_langs(unsigned int uid, stt_h stt, stt_supporte
        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 */
@@ -1269,18 +1252,10 @@ int stt_dbus_request_get_default_lang(unsigned int uid, char** language)
        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,
@@ -1342,48 +1317,7 @@ int stt_dbus_request_set_private_data(unsigned int uid, const char* key, const c
                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;
 }
 
@@ -1420,20 +1354,10 @@ int stt_dbus_request_get_private_data(unsigned int uid, const char* key, char**
        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,
@@ -1499,20 +1423,10 @@ int stt_dbus_request_is_recognition_type_supported(unsigned int uid, const char*
        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,
@@ -1572,48 +1486,7 @@ static int __stt_dbus_request_set_sound(int method, unsigned int uid, const char
                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;
 }
 
@@ -1639,48 +1512,7 @@ static int __stt_dbus_request_unset_sound(int method, unsigned int uid)
                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;
 }
 
@@ -1724,34 +1556,6 @@ int stt_dbus_request_unset_stop_sound(unsigned int uid)
        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) {
@@ -1790,52 +1594,13 @@ int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type,
                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)
@@ -1859,48 +1624,9 @@ 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)
@@ -1924,48 +1650,9 @@ 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