Add functions that use a private connection. 11/295611/2
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Mon, 10 Jul 2023 14:34:25 +0000 (16:34 +0200)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 14 Jul 2023 01:34:25 +0000 (01:34 +0000)
At the moment only the functions that libstorage uses are prepared.
Currently only functoins are added that are called by libstorage during
the dotnet-launcher preparation.

Change-Id: Idd7f145d1fef057cb5ba42039d006b491f5d7166

src/libgdbus/libgdbus.c
src/libgdbus/libgdbus.h

index 32c15ed..248bb67 100644 (file)
@@ -248,6 +248,7 @@ static dbus_handle_s *_gdbus_get_connection_private(GBusType bus_type)
 
        if (!dh->conn) {
                dh->conn = _get_bus_private(bus_type);
+               dh->priv = TRUE;
                dh->bus_type = bus_type;
                if (!dh->conn)
                        goto err;
@@ -2056,7 +2057,8 @@ int gdbus_flush_sync(dbus_handle_h handle)
        return ret;
 }
 
-int gdbus_call_sync_with_reply(const char *dest,
+int gdbus_priv_call_sync_with_reply(dbus_handle_h handle,
+                                               const char *dest,
                                                const char *path,
                                                const char *iface,
                                                const char *method,
@@ -2066,21 +2068,20 @@ int gdbus_call_sync_with_reply(const char *dest,
        GError *err = NULL;
        GVariant *reply = NULL;
        int ret = 0;
-       dbus_handle_s *dh = NULL;
+       dcl_gdbus();
 
-       if (!dest || !path || !iface || !method) {
-               _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
+       if (!dh) {
+               _E("dbus handle is NULL");
                if (param)
                        g_variant_unref(param);
                return -EINVAL;
        }
 
-       dh = _gdbus_get_default_connection();
-       if (!dh) {
-               _E("failed to get default connection, bustype:%d", (int)gdbus_get_default_bus_type());
+       if (!dest || !path || !iface || !method) {
+               _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
                if (param)
                        g_variant_unref(param);
-               return -ECOMM;
+               return -EINVAL;
        }
 
        reply = g_dbus_connection_call_sync(dh->conn,
@@ -2113,6 +2114,30 @@ int gdbus_call_sync_with_reply(const char *dest,
        return ret;
 }
 
+int gdbus_call_sync_with_reply(const char *dest,
+                                               const char *path,
+                                               const char *iface,
+                                               const char *method,
+                                               GVariant *param,
+                                               GVariant **out_reply)
+{
+       dbus_handle_s *dh = _gdbus_get_default_connection();
+       if (!dh) {
+               _E("failed to get default connection, bustype:%d", (int)gdbus_get_default_bus_type());
+               if (param)
+                       g_variant_unref(param);
+               return -ECOMM;
+       }
+
+       return gdbus_priv_call_sync_with_reply(dh,
+                                              dest,
+                                              path,
+                                              iface,
+                                              method,
+                                              param,
+                                              out_reply);
+}
+
 int gdbus_call_sync_with_reply_timeout(const char *dest, const char *path,
        const char *iface, const char *method, GVariant *param, GVariant **out_reply, int timeout)
 {
@@ -2527,6 +2552,7 @@ err:
        if (param)
                g_variant_unref(param);
        return ret;
+
 }
 
 int gdbus_call_pairs_async_with_reply(const char *dest,
index 659b2e4..87d5c81 100644 (file)
@@ -90,6 +90,8 @@ typedef struct {
 dbus_handle_h gdbus_get_connection     (GBusType bus_type,
                                                gboolean priv);
 
+int gdbus_free_connection(dbus_handle_h handle);
+
 int gdbus_request_name         (dbus_handle_h handle,
                                                const char *bus_name,
                                                GBusNameAcquiredCallback acquired_handler,
@@ -148,6 +150,14 @@ int gdbus_call_sync_with_reply             (const char *dest,
                                                                GVariant *param,
                                                                GVariant **out_reply);
 
+int gdbus_priv_call_sync_with_reply            (dbus_handle_h handle,
+                                                               const char *dest,
+                                                               const char *path,
+                                                               const char *iface,
+                                                               const char *method,
+                                                               GVariant *param,
+                                                               GVariant **out_reply);
+
 int gdbus_call_sync_with_reply_timeout (const char *dest,
                                                                const char *path,
                                                                const char *iface,