Extract dbus_connection_send 13/277413/1
authorwn.jang <wn.jang@samsung.com>
Wed, 6 Jul 2022 10:14:42 +0000 (19:14 +0900)
committerwn.jang <wn.jang@samsung.com>
Wed, 6 Jul 2022 10:14:42 +0000 (19:14 +0900)
Change-Id: I32f75c3f8e98da1e720f3d805985d3f4dcc97c26

server/sttd_dbus_server.c

index 3846c03..5dc1270 100644 (file)
 * Dbus Client-Daemon Server
 */
 
+static void __sttd_dbus_server_dbus_connection_send(DBusConnection* conn, DBusMessage* reply)
+{
+       if (!dbus_connection_send(conn, reply, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
+       }
+
+       dbus_connection_flush(conn);
+       dbus_message_unref(reply);
+       return;
+}
+
 int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
 {
        SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Hello");
@@ -30,19 +41,12 @@ int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
        if (NULL != reply) {
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -95,19 +99,12 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -128,12 +125,7 @@ static void __sttd_dbus_server_send_method_return(DBusConnection* conn, DBusMess
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
@@ -163,8 +155,6 @@ int sttd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
        __sttd_dbus_server_send_method_return(conn, msg, ret);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -256,19 +246,12 @@ int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -319,19 +302,12 @@ int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -375,12 +351,7 @@ int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
@@ -388,8 +359,6 @@ int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg)
        if (NULL != engine)     free(engine);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -435,19 +404,12 @@ int sttd_dbus_server_check_app_agreed(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -514,19 +476,12 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -570,12 +525,7 @@ int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
@@ -583,8 +533,6 @@ int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg)
        if (NULL != lang)       free(lang);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -617,8 +565,6 @@ int sttd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg)
        __sttd_dbus_server_send_method_return(conn, msg, ret);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -663,12 +609,7 @@ int sttd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
@@ -676,8 +617,6 @@ int sttd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
        if (NULL != data)       free(data);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -720,19 +659,12 @@ int sttd_dbus_server_is_recognition_type_supported(DBusConnection* conn, DBusMes
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
 
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
+               __sttd_dbus_server_dbus_connection_send(conn, reply);
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -761,8 +693,6 @@ int sttd_dbus_server_set_start_sound(DBusConnection* conn, DBusMessage* msg)
        __sttd_dbus_server_send_method_return(conn, msg, ret);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -790,8 +720,6 @@ int sttd_dbus_server_unset_start_sound(DBusConnection* conn, DBusMessage* msg)
        __sttd_dbus_server_send_method_return(conn, msg, ret);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -820,8 +748,6 @@ int sttd_dbus_server_set_stop_sound(DBusConnection* conn, DBusMessage* msg)
        __sttd_dbus_server_send_method_return(conn, msg, ret);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -849,8 +775,6 @@ int sttd_dbus_server_unset_stop_sound(DBusConnection* conn, DBusMessage* msg)
        __sttd_dbus_server_send_method_return(conn, msg, ret);
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -898,8 +822,6 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg)
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -933,8 +855,6 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -968,8 +888,6 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg)
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -1024,8 +942,6 @@ int sttd_dbus_server_start_file(DBusConnection* conn, DBusMessage* msg)
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }
 
@@ -1058,7 +974,5 @@ int sttd_dbus_server_cancel_file(DBusConnection* conn, DBusMessage* msg)
                }
        }
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
        return 0;
 }