Use libsyscommon for dbus 73/253673/7 accepted/tizen/unified/20210219.134923 submit/tizen/20210217.071642 submit/tizen/20210218.041307 submit/tizen/20210219.011639
authortaemin.yeom <taemin.yeom@samsung.com>
Tue, 16 Feb 2021 07:24:19 +0000 (16:24 +0900)
committertaemin.yeom <taemin.yeom@samsung.com>
Wed, 17 Feb 2021 06:48:43 +0000 (15:48 +0900)
Change-Id: I2779b674d8d45e3e4e76d4e52ea5523027c0c796
Signed-off-by: taemin.yeom <taemin.yeom@samsung.com>
CMakeLists.txt
packaging/capi-system-runtime-info.spec
src/runtime_info_usage.c

index 4b27def..a4ed08a 100755 (executable)
@@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-SET(requires "dlog vconf capi-base-common capi-system-info glib-2.0 gio-2.0 hal-api-common hal-api-device")
+SET(requires "dlog vconf capi-base-common capi-system-info glib-2.0 gio-2.0 libsyscommon hal-api-common hal-api-device")
 SET(pc_requires "capi-base-common")
 
 INCLUDE(FindPkgConfig)
index 39500d6..ff1a11a 100644 (file)
@@ -13,6 +13,7 @@ BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(libsyscommon)
 BuildRequires:  pkgconfig(hal-api-common)
 BuildRequires:  pkgconfig(hal-api-device)
 Requires(post): /sbin/ldconfig
index dacf4a5..f209cc9 100644 (file)
 #include <unistd.h>
 #include <stdarg.h>
 
+#include <libsyscommon/dbus-system.h>
 #include <dlog.h>
 
 #include <runtime_info.h>
 #include <runtime_info_private.h>
 #include <runtime_info-internal.h>
 
-#include <gio/gio.h>
 #include <glib.h>
 
 #include <hal/device/hal-memory.h>
@@ -89,8 +89,6 @@ static GVariant *runtime_info_append_args(int *args, int size)
 static GVariant *runtime_info_dbus_request_usage_info(runtime_info_usage_type_e type,
                int *pid, int size, int *error)
 {
-       static GDBusConnection *conn;
-       GError *err = NULL;
        GVariant *args_in = NULL;
        GVariant *args_out = NULL;
        GVariant *usage;
@@ -153,39 +151,18 @@ static GVariant *runtime_info_dbus_request_usage_info(runtime_info_usage_type_e
                break;
        }
 
-       /* Send message to resourced and receive reply */
-       if (!conn) {
-               conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-               if (!conn) {
-                       //LCOV_EXCL_START : system error
-                       _E("Failed to get dbus connection : %s",
-                                       err && err->message ? err->message : NULL);
-                       if (args_in)
-                               g_variant_unref(args_in);
-                       return NULL;
-                       //LCOV_EXCL_STOP
-               }
-       }
-
        _D("Process %d: Sending dbus message to resourced for %s info",
                        getpid(), dbus_info[type].caption);
-
-       args_out = g_dbus_connection_call_sync(conn,
-                               RESOURCED_BUS_NAME,
+       args_out = dbus_handle_method_sync_with_reply_var(RESOURCED_BUS_NAME,
                                RESOURCED_USAGE_OBJECT_NAME,
                                RESOURCED_USAGE_INTERFACE_NAME,
                                dbus_info[type].method_name,
-                               args_in, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, NULL, &err);
+                               args_in);
+
        if (!args_out) {
                //LCOV_EXCL_START : system error
-               _E("DBUS_METHOD_CALL: not able to send message : %s",
-                               err && err->message ? err->message : NULL);
-               if (err && (err->code == G_FILE_ERROR_TXTBSY))
-                       *error = RUNTIME_INFO_ERROR_PERMISSION_DENIED;
-               else
-                       *error = RUNTIME_INFO_ERROR_REMOTE_IO;
-               if (args_in && !err)
-                       g_variant_unref(args_in);
+               _E("DBUS_METHOD_CALL: not able to send message");
+
                return NULL;
                //LCOV_EXCL_STOP
        }