From 570d24b88ca82332d472dcb562f5e0d825d63cf2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 23 Dec 2015 14:07:36 +0100 Subject: [PATCH] libnm/tests: add dbus-glib support to "nm-test-libnm-utils" --- shared/nm-test-libnm-utils.h | 5 +++++ shared/nm-test-utils-impl.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/shared/nm-test-libnm-utils.h b/shared/nm-test-libnm-utils.h index dad5638f9f..9645b9edff 100644 --- a/shared/nm-test-libnm-utils.h +++ b/shared/nm-test-libnm-utils.h @@ -29,6 +29,11 @@ typedef struct { GDBusProxy *proxy; GPid pid; int keepalive_fd; +#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) + struct { + DBusGConnection *bus; + } libdbus; +#endif } NMTstcServiceInfo; NMTstcServiceInfo *nmtstc_service_init (void); diff --git a/shared/nm-test-utils-impl.c b/shared/nm-test-utils-impl.c index 91bf8b3c0c..fc6d6c2af8 100644 --- a/shared/nm-test-utils-impl.c +++ b/shared/nm-test-utils-impl.c @@ -26,8 +26,14 @@ #include "NetworkManager.h" #include "nm-dbus-compat.h" +#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) +#include "nm-dbus-glib-types.h" +#endif + #include "nm-test-libnm-utils.h" +/*****************************************************************************/ + static gboolean name_exists (GDBusConnection *c, const char *name) { @@ -94,6 +100,11 @@ nmtstc_service_init (void) NULL, &error); g_assert_no_error (error); +#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) + info->libdbus.bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + g_assert_no_error (error); + g_assert (info->libdbus.bus); +#endif return info; } @@ -116,6 +127,10 @@ nmtstc_service_cleanup (NMTstcServiceInfo *info) g_object_unref (info->bus); close (info->keepalive_fd); +#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) + g_clear_pointer (&info->libdbus.bus, dbus_g_connection_unref); +#endif + memset (info, 0, sizeof (*info)); g_free (info); }