Use libsyscommon for dbus 02/258402/1 tizen_6.0
authortaemin.yeom <taemin.yeom@samsung.com>
Tue, 16 Feb 2021 07:24:19 +0000 (16:24 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 17 May 2021 01:39:49 +0000 (10:39 +0900)
Change-Id: I2779b674d8d45e3e4e76d4e52ea5523027c0c796
Signed-off-by: taemin.yeom <taemin.yeom@samsung.com>
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
packaging/capi-system-runtime-info.spec
src/runtime_info_usage.c

index ccd525b0c680bad9b6c4179095b9984c021485ad..9d9779aee2bfa7fdb662bb128c45ff6095399d65 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")
+SET(requires "dlog vconf capi-base-common capi-system-info glib-2.0 gio-2.0 libsyscommon")
 SET(pc_requires "capi-base-common")
 
 INCLUDE(FindPkgConfig)
index bab433b3c7c74f98fd062902e019357b816f37b5..8966c53ae45b4fd8fa57b489d53ba05269862212 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)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
index 64120d231b14d3af6138418f06e7989960bdbc99..647206b87f7e4b4dc728e866ae2051be11ceed7c 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+#include <libsyscommon/dbus-system.h>
 #include <dlog.h>
 
 #include <runtime_info.h>
 #include <runtime_info_private.h>
 
-#include <gio/gio.h>
 #include <glib.h>
 
 #define RESOURCED_BUS_NAME "org.tizen.resourced"
@@ -83,8 +83,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;
@@ -145,39 +143,17 @@ 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->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
        }