From 80763a83d81c74cc1491af875aac55cd5d2d925c Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Wed, 29 Jun 2016 22:37:24 -0700 Subject: [PATCH] libnm-glib is deprecated and may not be available. This patch switches to use th enew libnm API, also snice nm_client_new now takes a GError, I thought I'd report the error message if mission control can't connect to the network manager. Additionally we can remove a definition of the NM_CHECK_VERSION macro for old versions of NM, as well as a guard for the NM_STATE_DISCONNECTING constant. --- configure.ac | 2 +- src/connectivity-monitor.c | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 5be3c80..f999ce6 100644 --- a/configure.ac +++ b/configure.ac @@ -193,7 +193,7 @@ if test "x$with_connectivity" = "xno" || test "x$with_connectivity" = "xconnman" else PKG_CHECK_MODULES(NETWORK_MANAGER, [ - libnm-glib >= 0.7.0 + libnm ], have_nm="yes", have_nm="no") if test "x$have_nm" = "xyes"; then diff --git a/src/connectivity-monitor.c b/src/connectivity-monitor.c index 288d6f5..f3c3a61 100644 --- a/src/connectivity-monitor.c +++ b/src/connectivity-monitor.c @@ -32,7 +32,7 @@ #endif #ifdef HAVE_NM -#include +#include #endif #include @@ -182,10 +182,6 @@ connectivity_monitor_remove_states ( #ifdef HAVE_NM -#if !defined(NM_CHECK_VERSION) -#define NM_CHECK_VERSION(x,y,z) 0 -#endif - static void connectivity_monitor_nm_state_change_cb (NMClient *client, const GParamSpec *pspec, @@ -202,9 +198,7 @@ connectivity_monitor_nm_state_change_cb (NMClient *client, state = nm_client_get_state (priv->nm_client); if (state == NM_STATE_CONNECTING -#if NM_CHECK_VERSION(0,8,992) || state == NM_STATE_DISCONNECTING -#endif || state == NM_STATE_ASLEEP) { DEBUG ("New NetworkManager network state %d (unstable state)", state); @@ -459,6 +453,7 @@ static void mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) { McdConnectivityMonitorPrivate *priv; + GError *error = NULL; priv = G_TYPE_INSTANCE_GET_PRIVATE (connectivity_monitor, MCD_TYPE_CONNECTIVITY_MONITOR, McdConnectivityMonitorPrivate); @@ -487,7 +482,7 @@ mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) #endif #ifdef HAVE_NM - priv->nm_client = nm_client_new (); + priv->nm_client = nm_client_new (NULL, &error); if (priv->nm_client != NULL) { priv->state_change_signal_id = g_signal_connect (priv->nm_client, @@ -498,7 +493,7 @@ mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) } else { - DEBUG ("Failed to get NetworkManager proxy"); + DEBUG ("Failed to get NetworkManager proxy: %s", error->message); } #endif -- 2.8.1