diff options
Diffstat (limited to 'shared/nm-test-libnm-utils.h')
| -rw-r--r-- | shared/nm-test-libnm-utils.h | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/shared/nm-test-libnm-utils.h b/shared/nm-test-libnm-utils.h index 192c089e..20a15e5f 100644 --- a/shared/nm-test-libnm-utils.h +++ b/shared/nm-test-libnm-utils.h @@ -22,6 +22,10 @@ #include "nm-utils/nm-test-utils.h" +#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB +#include "nm-dbus-glib-types.h" +#endif + /*****************************************************************************/ typedef struct { @@ -29,7 +33,7 @@ typedef struct { GDBusProxy *proxy; GPid pid; int keepalive_fd; -#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) +#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB struct { DBusGConnection *bus; } libdbus; @@ -38,23 +42,35 @@ typedef struct { NMTstcServiceInfo *nmtstc_service_init (void); void nmtstc_service_cleanup (NMTstcServiceInfo *info); +NMTstcServiceInfo *nmtstc_service_available (NMTstcServiceInfo *info); static inline void _nmtstc_auto_service_cleanup (NMTstcServiceInfo **info) { - if (info && *info) { - nmtstc_service_cleanup (*info); - *info = NULL; - } + nmtstc_service_cleanup (g_steal_pointer (info)); } - #define NMTSTC_SERVICE_INFO_SETUP(sinfo) \ NM_PRAGMA_WARNING_DISABLE ("-Wunused-variable") \ - __attribute__ ((cleanup(_nmtstc_auto_service_cleanup))) NMTstcServiceInfo *sinfo = nmtstc_service_init (); \ + __attribute__ ((cleanup(_nmtstc_auto_service_cleanup))) NMTstcServiceInfo *sinfo = ({ \ + NMTstcServiceInfo *_sinfo; \ + \ + _sinfo = nmtstc_service_init (); \ + if (!nmtstc_service_available (_sinfo)) \ + return; \ + _sinfo; \ + }); \ NM_PRAGMA_WARNING_REENABLE /*****************************************************************************/ -#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB) +#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB + +#include "nm-client.h" +#include "nm-remote-settings.h" + +NMClient *nmtstc_nm_client_new (void); +NMRemoteSettings *nmtstc_nm_remote_settings_new (void); + +#else NMDevice *nmtstc_service_add_device (NMTstcServiceInfo *info, NMClient *client, @@ -67,17 +83,9 @@ NMDevice * nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo, const char *hwaddr, const char **subchannels); -#endif /* NM_NETWORKMANAGER_COMPILATION_LIB */ - -#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) - -#include "nm-client.h" -#include "nm-remote-settings.h" - -NMClient *nmtstc_nm_client_new (void); -NMRemoteSettings *nmtstc_nm_remote_settings_new (void); +#endif -#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */ +/*****************************************************************************/ void nmtstc_service_add_connection (NMTstcServiceInfo *sinfo, NMConnection *connection, |