libnm/tests: add dbus-glib support to "nm-test-libnm-utils"

This commit is contained in:
Thomas Haller 2015-12-23 14:07:36 +01:00
parent c0af56ac7a
commit 570d24b88c
2 changed files with 20 additions and 0 deletions

View 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);

View file

@ -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);
}