From: Mateusz Moscicki Date: Mon, 10 Jul 2023 14:34:25 +0000 (+0200) Subject: Add functions that use a private connection. X-Git-Tag: accepted/tizen/unified/riscv/20230718.003634~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e087d5b9256880dfccffde7f99470e7498fa3c1;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git Add functions that use a private connection. 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 --- diff --git a/src/libgdbus/libgdbus.c b/src/libgdbus/libgdbus.c index 32c15ed..248bb67 100644 --- a/src/libgdbus/libgdbus.c +++ b/src/libgdbus/libgdbus.c @@ -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, diff --git a/src/libgdbus/libgdbus.h b/src/libgdbus/libgdbus.h index 659b2e4..87d5c81 100644 --- a/src/libgdbus/libgdbus.h +++ b/src/libgdbus/libgdbus.h @@ -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,