libnm/tests: add dbus-glib support to "nm-test-libnm-utils"
authorThomas Haller <thaller@redhat.com>
Wed, 23 Dec 2015 13:07:36 +0000 (14:07 +0100)
committerThomas Haller <thaller@redhat.com>
Sat, 26 Dec 2015 15:43:49 +0000 (16:43 +0100)
shared/nm-test-libnm-utils.h
shared/nm-test-utils-impl.c

index dad5638..9645b9e 100644 (file)
@@ -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);
index 91bf8b3..fc6d6c2 100644 (file)
 #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);
 }